-->
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.  [ 3 posts ] 
Author Message
 Post subject: Hibernate.isInitialized when session is open
PostPosted: Thu Feb 05, 2009 5:24 am 
Newbie

Joined: Thu Nov 15, 2007 3:17 am
Posts: 19
Hi,

I want to check if some entities property has already been loaded (= is not lazy anymore). I tried Hibernate.isInitialized(proxy) but it seems while there is an active session attached the method returns true everytime. When I invoke this method when session is closed the method returns false (= estimated behavior).

Is there another way how I can check if a property has already been loaded while session is still active?

TIA byto


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 05, 2009 11:48 am 
Red Hat Associate
Red Hat Associate

Joined: Mon Aug 16, 2004 11:14 am
Posts: 253
Location: Raleigh, NC
That's what the method you're using is for. Are you saying it returns true and the proxy is *not* initialized? If so, provide all the info requested (version, mappings, code, errors, etc) on the forum and someone may have a look.

_________________
Chris Bredesen
Senior Software Maintenance Engineer, JBoss


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 05, 2009 3:55 pm 
Newbie

Joined: Thu Nov 15, 2007 3:17 am
Posts: 19
Let me try to explain it a bit better:

e.g. there is an entity A with a (lazy) one-to-many relation to entity B. Now I load the A entities by HQL query "from A". Hibernate selects the data from the database without fetching the B entities. When I now use Hibernate.isInitialized() on some A.B proxy, the method returns true although B has not yet been loaded.

Im looking for a way to check if A.B has already been loaded from the database, even if the collection still is attached to a hibernate session. Hibernate.isInitialized() returns false when the property has not been loaded and the entity is detached. But it returns true if the collection is still attached but the property has not yet been loaded.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.