Inside a Session, Hibernate keeps a snapshot of the original state
of a collection and so can do removals/additions individually.

However, an object that came into the session via a call to update()
may have had all kind of things done to it (a PersistentCollection
completely replaced with a transient Collectin, for example). So we
can't really have been tracking changes. In this case Hibernate
simply removes all the existing rows using a single DELETE or
UPDATE and then recreates the whole collection, based upon the new
state of the object that was passed to update().

Think of update() as "trash whatever was there and use this instead".
OTOH, load() followed by flush() means "grab the existing state and
then carefully make any necessary adjustments".


> How does Hibernate decide/track how to delete, update, insert tuples based
> on what the user has added and/or removed in the sets/lists representing
> many-to-one and many-to-many mappings ?
>
> (the question just came to my mind when i saw:  "P.S. Hibernate is *not*
> tracking which objects were removed from the collection (also a Good
> Thing)." - and I came to think: Ok, but then how does it decide to do a
> delete of something if it does not track deletions :)
> (I guess there are an simple and an more advanced explanation - I like them
> both :)




-------------------------------------------------------
This SF.NET email is sponsored by: Thawte.com - A 128-bit supercerts will
allow you to extend the highest allowed 128 bit encryption to all your 
clients even if they use browsers that are limited to 40 bit encryption. 
Get a guide here:http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0030en
_______________________________________________
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to