hi,
i have a question about, in particular i'd like to know, whether i do understand the purpose if this method correctly.
a Session is a first level cache and it memorizes the objects that working with the session (are associated with the session). if i want to associate an object twice i get the NonUniqueObjectException, if i use a transient or detached object without associating it with a session, i get a 'No session' exception when i want to refresh the object or access associated object from this object (i.e. relations in the database).
if an object is associated with a session, the contains(object) method is supposed to return 'true', isn't it?
i've run into serious problems in my application because somehow the method does not always return the correct value. if the contains() method returns 'false' i try to get a lock on the obect, thus reassociating it with the current new session, but on many occasions i get a NonUniqueObjectException allthough the contains method returned 'false', thus rendering the session useless.
the method uses the equals() method of the objects to check for existing associated objects?!??!
this is really a problem because i need a reliable mechnism to check whether a object is already associated to reattach it or not.
i didn't find a solution anywhere and i'm not experienced with hibernate, so some help here from some experienced users would be great!!
thx in advance,
greetings, -ben
|