That is exactly what I was looking for.

Thanks again for a great tool.

Regards,
John

-----Original Message-----
From: Gavin King [mailto:[EMAIL PROTECTED]
Sent: Saturday, October 18, 2003 6:06 AM
To: Urberg, John
Cc: '[EMAIL PROTECTED]'
Subject: Re: [Hibernate] Saving Collections from Multiple Sessions


You need to upgrade to Hibernate 2.1, and understand the 
select-before-update mapping
attribute.

Urberg, John wrote:

>Hibernate also seems to always assume objects from different sessions are
>dirty.  (I'm using saveOrUpdate() in 1.2.5.  Maybe this has changed in
2.*?)
>
>Anyway, I need to work around this to be able to use Hibernate in a 3-tier
>system.  I can only have SQL created when an object is really dirty since
>there are triggers in the database.  So here are the changes I think could
>accomplish my goals:
>
>1) Upgrade to 2.* so I can use the latest features on the Interceptor
>2) Add code to handle unsaved-values correctly on objects with
>composite-ids.
>3) Modify SessionImpl to bypass Collection updating in
>removeCollectionsFor() and prepareCollectionsForUpdate() (I mentioned this
>in the last post).
>4) Add a method to our base Domain Object class to return dependent
objects.
>Each domain object class will then need to return the collections of
objects
>that need to get updated when it is updated.  This will be a manual work
>around for cascading on collections since I disabled that in step #3
>5) Modify my transaction management code to set WAIT_FOR_COMMIT = true
>during the transactions since we can't control the order dependent objects
>get because of #3 & #4.
>6) Add methods to our base Domain Object class to capture the original
value
>of a property when it changes.  The Domain Object class will then have a
has
>map with the original values of only the properties that changed.  If the
>map is empty, the object is not dirty.
>7) In Intercepter.findDirty(), determine the properties that changed based
>on #6.
>
>If this works, the only changes I'd have to make in Hibernate proper would
>be a switch to disable the collections stuff.  The rest would be in a
custom
>Interceptor and my code.
>
>Please let me know if this looks like a reasonable way to make Hibernate
>function in a 3-tier environment.  
>
>Thanks,
>John    
>
>-----Original Message-----
>From: Urberg, John [mailto:[EMAIL PROTECTED]
>Sent: Thursday, October 16, 2003 11:21 AM
>To: '[EMAIL PROTECTED]'
>Subject: [Hibernate] Saving Collections from Multiple Sessions
>
>
>We have a 3-tier Java GUI application using Hibernate as the O/R mapping
>layer.  We've run into the problem of dealing with updating collections
from
>other sessions.  It seems Hibernate will recreate the collection if the
>collection was loaded with a different persisted (see
>SessionImpl.prepareCollectionForUpdate()).  This is always the case in my
>app since we send domain objects to the client and then send them back to
>the server to be updated.
>
>I'm thinking about doing the following to work around this until I can come
>up with a better idea:
>
>1) Add a "ignoreCollections" flag to Session with a default of false.  When
>set to true, it will skip the prepareCollectionsForUpdate method.
>2) Classes with collections that need to be updated will implement the
>Lifecycle interface and manually cascade the changes.
>
>Does this sound like a workable solution?
>
>Regards,
>John Urberg
>
>Software is not limited by physics, like buildings are. It is limited by
>imagination, by design, by organization. In short, it is limited by
>properties of people, not by properties of the world. "We have met the
>enemy, and he is us." - Ralph Johnson


-------------------------------------------------------
This SF.net email sponsored by: Enterprise Linux Forum Conference & Expo
The Event For Linux Datacenter Solutions & Strategies in The Enterprise 
Linux in the Boardroom; in the Front Office; & in the Server Room 
http://www.enterpriselinuxforum.com
_______________________________________________
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to