-->
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.  [ 2 posts ] 
Author Message
 Post subject: Objects in session (entitiesByKey) inconsistent with db
PostPosted: Mon May 07, 2007 11:37 am 
Newbie

Joined: Wed Nov 30, 2005 4:40 pm
Posts: 14
Location: St. Louis MO.
I have a situation today where the following method is returning a stale version of an object. When I look at the database, it is current! I have set a break point in my IDE and drilled into the PersistentContext. I see the object in the entityByKey Map, and it is stale. Any ideas?

public Object getObject(Class clazz, Long id) {
try {
begin();
Object o = sess.get(clazz, id);
commit();
log.debug("getObject(Class clazz, long id) returning:" + o);
return o;
} catch (HibernateException e) {
log.error(e);
commit();
return null;
}
}

Thanks,
Scott


Top
 Profile  
 
 Post subject: factory.getSession & session.close()
PostPosted: Mon May 07, 2007 5:59 pm 
Newbie

Joined: Wed Nov 30, 2005 4:40 pm
Posts: 14
Location: St. Louis MO.
Is session.close() required in 3.1? Also, what are the implications of

<property name="transaction.auto_close_session">true</property>

I have been chasing the strangest problems between the data in the database and the object representation as per sess.get(id). I happened on to this hibernate property, and it seems to have fixed everything! I have read the docs and also own the new JPA book. If this discussion is in either place, can you please refer me to the reading. I realize this ties into TX, but either it is not well explained or is in the wrong location.

On page 388 in JPA, the first line on the page discusses a UOW ending and closing the persistence context. Wow! Where is the UOW formally defined and what is meant by closing the persistence context? Is this closing the session, and now we are back to the original question!

Scott


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

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.