...by the way... I think this (solved) Hibernate issue might be the same thing 
I've noticed
http://opensource.atlassian.com/projects/hibernate/browse/EJB-237

/R

From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Fabio 
Maulo
Sent: den 9 oktober 2008 22:12
To: [email protected]
Subject: [nhusers] Re: Session.Merge() -> session dirty

it depend on what you are doing in ent.DeepCloneOfAggregate() and in "..."

I don't understand various things...
1) why use session.Lock when the Merge reattach the entity to the new session ?
2) why use a clone when Merge return an updated version of your entity without 
touch the original one ?

doc of Merge
                                            /// Copy the state of the given 
object onto the persistent object with the same
                                            /// identifier. If there is no 
persistent instance currently associated with
                                            /// the session, it will be loaded. 
Return the persistent instance. If the
                                            /// given instance is unsaved, save 
a copy of and return it as a newly persistent
                                            /// instance. The given instance 
does not become associated with the session.
                                            /// This operation cascades to 
associated instances if the association is mapped
                                            /// with cascade="merge".


2008/10/9 Roger Kratz <[EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]>>

Hi



Is this suppose to work?



Entity ent=[...];

Entity entClone =ent.DeepCloneOfAggregate();

...

session.Lock(ent, LockMode.None);

session.Merge(entClone); <--has not been changed

Assert.IsFalse(session.IsDirty());





It works if "ent" does not have any collection. If it has, the session becomes 
dirty.



If "ent" is not versioned/has optimistic lock, nothing will be persisted. 
However, because entity is considered dirty, if flushing this session, "ent" 
will be persisted to the db with a new version number even though no data has 
been changed.



Is this by design or is this a bug that I should JIRA this?



/Roger









--
Fabio Maulo


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to