session.merge is not very smart. Hibernate will update all properties and association table. For association, delete all related rows, and then add, even if the association(such as colllection) is not changed. Is there a better way other than merge?  Thanks.

Werner Punz <[EMAIL PROTECTED]> wrote:
Mario Ivankovits schrieb:
> Hi!
>> session.lock(object, LockMode.NONE)
> This might also fail if the object already exists in the current
> session, no?
>
> You can safely reattach the object using
>
> object = session.merge(object)
>
> Though, you really should discard the old object then and work further
> with the new one.
>
Just to add additional comments.
Session merge is a convenience method introduced in Hiberante 3.1 (and
EJB3) due to the fact that the having an object coming in over session
boundaries and doing a simple save or update simply caused to many
problems (constantly clashes with objects already loaded by predecessing
queries)

Thus session.merge und session.persist were introduced.




Relax. Yahoo! Mail virus scanning helps detect nasty viruses!

Reply via email to