-->
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: Learnings and questions PersistenceContextType, cache, lazy
PostPosted: Tue Mar 22, 2011 4:21 am 
Newbie

Joined: Sat Feb 18, 2006 1:44 am
Posts: 15
When we use PersistenceContextType.TRANSACTION
changes we make to a disconnected entity wont be visible if we again obtain the entity using its id
and these changes will be lost if we update the freshly gotten same entity and save it.
This is because the freshly gotten entity is got by executing a select.
Further more if lazy fields had not been obtained when connected after a disconnect attempting to access the lazy field will give lazy initialization exception.

When we use PersistenceContextType.EXTENDED
changes we make to a disconnected entity will be visible if we again obtain the entity using its id
and these changes will be not lost if we update the freshly gotten same entity and save it.
This is because the freshly gotten entity is NOT got by executing a select.
Further more if lazy fields had not been obtained when connected after a disconnect attempting to access the lazy field will NOT give lazy initialization exception.

So need to learn about the entity cache. Any pointers?

getReference and find.
We should use EntityManager.getReference when we need state to be lazily fetched where permitted (Define permitted).
Will using EntityManager.find method really get all the fields? Where dioes it stop.

When is lazy permitted?
Marking a joined entity as EAGER in orm.xml is still keeping it lazy when parent entity is accessed by getReference. Why?


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.