-->
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.  [ 4 posts ] 
Author Message
 Post subject: SaveAndUpdateCopy - Fails with Transient in Inverse Coll
PostPosted: Mon Jan 16, 2006 11:28 pm 
Beginner
Beginner

Joined: Mon Aug 15, 2005 11:09 pm
Posts: 23
I have a 'Load' Object with a one-to-many inverse relationship (bag) containing 'Pickup' Objects. Both have been created outside of the session (on a rich client). Every 'Pickup' requires a 'Load'.

The following fails to work
Code:
'Outside of the session
'After creating a new load and pickup
pickup.load = load
load.Pickups.Add(pickup)

'In the session
session.SaveAndUpdateCopy(load) 'This fails
session.SaveAndUpdateCopy(pickup)


The exception is:

Code:
WasteLinkEntityTest.IntegrationTest.DataAccessBroker.NHibernateScopeTest.TestCollectionInverseSave : NHibernate.TransientObjectException : object references an unsaved transient instance - save the transient instance before flushing: WasteLinkWebService.Entity.Transport.Pickup
  at NHibernate.Impl.SessionImpl.ThrowTransientObjectException(Object obj)
   at NHibernate.Impl.SessionImpl.GetEntityIdentifierIfNotUnsaved(Object obj)
   at NHibernate.Type.EntityType.GetIdentifier(Object value, ISessionImplementor session)
   at NHibernate.Type.EntityType.Copy(Object original, Object target, ISessionImplementor session, Object owner, IDictionary copyCache)
   at NHibernate.Type.PersistentCollectionType.CopyElement(ICollectionPersister persister, Object element, ISessionImplementor session, Object owner, IDictionary copiedAlready)
   at NHibernate.Type.PersistentCollectionType.Copy(Object original, Object target, ISessionImplementor session, Object owner, IDictionary copiedAlready)
   at NHibernate.Type.TypeFactory.Copy(Object[] original, Object[] target, IType[] types, ISessionImplementor session, Object owner, IDictionary copiedAlready)
   at NHibernate.Impl.SessionImpl.DoCopy(Object obj, Object id, IDictionary copiedAlready)
   at NHibernate.Impl.SessionImpl.SaveOrUpdateCopy(Object obj)
   at WasteLinkWebService.DataAccess.DatabaseBroker.SaveOrUpdate(Object obj) in c:\inetpub\wwwroot\WasteLinkWebService\DataAccess\DatabaseBroker.vb:line 103


Now it works fine if SaveAndUpdateCopy is replaced with SaveAndUpdate. SaveAndUpdate simply ignores the collection since it's an inverse. Obviously the copy has issues copying the transient objects, but because the collection is an inverse I can't see why it matters whether the collection contains persistent or transient objects.

At the moment I'm not sure if this is simply an inherit limitation imposed when using the copy version, or if this is an actual issue.

This problem can be worked around by copying the transient collection elements to a temporary collection, but it's very tedious and breaks the encapsulation model. Moreso when there are multiple levels of one-to-manys. We've settled on including a transientBlahCollection on the objects but that's a horrible design smell.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 30, 2006 12:46 am 
Beginner
Beginner

Joined: Mon Aug 15, 2005 11:09 pm
Posts: 23
Any thoughts or should I add it to JIRA?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 30, 2006 6:42 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Report it please.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 08, 2006 2:02 pm 
Expert
Expert

Joined: Fri Oct 28, 2005 5:38 pm
Posts: 390
Location: Cedarburg, WI
Was this reported in JIRA? The NHibernate JIRA site seems to be down (I can get at Hibernate's OK, so it doesn't seem to be on my end). The list of bugs fixed in 1.0.3 didn't mention anything like this one ...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.