Using Hibernate 3.2.6GA and EntityManager 3.3.2GA
Let's say I have created the following set of classes (pseudo/partial code)
User
dbId DB generatedlong
loginid unique string
name string
firstname string
<set name="belongings" table="lt_user_things">
<key column="user_id" foreign-key="fk_user_things"/>
<many-to-many class="Thing" column="thing_id" foreign-key="fk_things_user"/>
</set>
Thing
dbId DB generatedlong
name string
...
cascading is defaulting to all in all my hibernate defined entities
in my J2EE web svc I am caching the users into a
private static ConcurrentHashMap<String, User> hm_users = new ConcurrentHashMap<String, User>();
because I do not want to spend too much time doing find(User, id)
as users rarely change
Reading through various documentation, I thought that when
leaving a session where my User object was persistent and entering a new
one later on in detached state I could still update the User structure at this point
using entitymgr.merge if the object was still coherent with the DB contents
however it seems like it does not work for some of the user attributes and
subobjects (like things) are not really usable either
I also tried calling
((org.hibernate.impl.SessionImpl) this.manager.getDelegate()).lock(user, LockMode.NONE);
to "re-attach" the data with the DB contents but without more luck
Can someone see anything I am missing there
Thanks
|