-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: NHibernate tries to re-save collection for "read only" obj
PostPosted: Thu Dec 02, 2010 3:44 pm 
Newbie

Joined: Fri Dec 08, 2006 6:26 pm
Posts: 5
Hi, I wonder if someone can explain this situation

I read an object of class A. This class A contains an <set> called RelatedSections.

I get the object of class A for READ ONLY purposes but when trying to flush the session after saving another object of class B (not related with class A at all) I get an exception because NHibernate tried to re-save RelatedEntities

Why tries to re-save an object that wasn't touched at all?????

I'm using NHibernate 1.2

Here the exception

Code:
[SqlException (0x80131904): Violation of PRIMARY KEY constraint 'PK_System_Widgets_SectionGroupsSections'. Cannot insert duplicate key in object 'dbo.System_Widgets_SectionGroupsSections'.
The statement has been terminated.]
   System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +1951450
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +4849003
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +194
   System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2394
   System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +204
   System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +954
   System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +162
   System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +175
   System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +137
   NHibernate.Impl.BatcherImpl.ExecuteNonQuery(IDbCommand cmd) +32
   NHibernate.Impl.NonBatchingBatcher.AddToBatch(IExpectation expectation) +16
   NHibernate.Persister.Collection.AbstractCollectionPersister.InsertRows(IPersistentCollection collection, Object id, ISessionImplementor session) +723

[ADOException: could not insert collection rows: [AdminCms.BusinessObjects.Widgets.WidgetSectionGroup.RelatedSections#34]]
   NHibernate.Persister.Collection.AbstractCollectionPersister.InsertRows(IPersistentCollection collection, Object id, ISessionImplementor session) +1024
   NHibernate.Impl.ScheduledCollectionUpdate.Execute() +247
   NHibernate.Impl.SessionImpl.Execute(IExecutable executable) +108
   NHibernate.Impl.SessionImpl.ExecuteAll(IList list) +83
   NHibernate.Impl.SessionImpl.Execute() +199
   NHibernate.Impl.SessionImpl.Flush() +45
   AdminCms.DataAccessObjects.Base.BaseDAO`2.Save(T entity) in D:\Sources\Gecko\AdminCms.DataAccessObjects\Base\BaseDAO.cs:52
   AdminCms.BusinessServices.MostViewed.MostViewed.RecordHitArticleEmailed(HitArticleEmailed hit) in D:\Sources\Gecko\AdminCms.BusinessServices\MostViewed\MostViewed.cs:44
   NewsMerged.UserControls.EmailFriend.RecordArticleEmailed(Int32 arId) in D:\Sources\Gecko\NewsWeb\UserControls\EmailFriend.ascx.cs:201
   NewsMerged.UserControls.EmailFriend.btnMailIt_Click(Object sender, EventArgs e) in D:\Sources\Gecko\NewsWeb\UserControls\EmailFriend.ascx.cs:194
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565



Top
 Profile  
 
 Post subject: Re: NHibernate tries to re-save collection for "read only" obj
PostPosted: Thu Dec 02, 2010 4:20 pm 
Newbie

Joined: Fri Dec 08, 2006 6:26 pm
Posts: 5
Please, anyone?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.