-->
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: Object references for POJOs
PostPosted: Mon Jan 22, 2007 1:00 pm 
Senior
Senior

Joined: Mon Jul 24, 2006 8:43 am
Posts: 160
Hi,
I am using hibernate in standalone mode (i.e. not using an app server or container).
I was trying to investigate if hibernate does anything special for object references to persistence POJOs.
More specifically:
there is a persistent POJO called Person, my first persistent reference to this is called person1.
Another thread, runs a query with the primary key for this person and the result is the person2 reference.
Now, in some cases hibernate is smart enough to update person2 to be pointing at the same memory address as person1.
This seems to be when both threads use the same EntityManager reference.
But in other cases, if the thread use different EntityManager references, hibernate will do no smart updated, so each thread's object reference will point to a different memory address, even though it is the same POJO.
I have discovered this by some debugging etc, just want to make sure I am correct?
It appears that hibernate cache's the POJO entity per entity manager,is there any restriction / limitations to this cache.
Cheers


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 24, 2007 3:47 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
reusing the same instance across different threads is not smart :-)
I would recommend you to read carefully the reference documentation or preferable, go and get a copy of Java Persistence with Hibernate, you'll understand the issues

_________________
Emmanuel


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.