-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Problem trying to re-attach objects when using EntityManager
PostPosted: Tue Dec 02, 2008 3:21 am 
Beginner
Beginner

Joined: Sat Jan 05, 2008 7:33 am
Posts: 26
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.