-->
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: Detecting if a lazy loaded collection is initialized or not
PostPosted: Wed Oct 19, 2005 10:38 am 
Newbie

Joined: Mon Mar 08, 2004 2:05 pm
Posts: 4
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

[b]Hibernate version: 3.0.5

I have a hibernate pojo that contains a collection which is lazily loaded.

My usecase: I want to log the contents of this Pojo.

My Problem: In my logging routine if I access the collection property this will automatically initialize it (hit the DB --> performance impact just for logging). What I want to do is to modify my logging logic to identify if the collection was initialized or not. If not initialized, I just want to print: "Not yet Initialized" otherwise I will print the content of the collection


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 19, 2005 11:22 am 
Beginner
Beginner

Joined: Tue Nov 25, 2003 3:33 pm
Posts: 35
use

Code:
YourPojo p;
Hibernate.isInitialized(p.getAssociationCollection());


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 19, 2005 12:14 pm 
Newbie

Joined: Mon Mar 08, 2004 2:05 pm
Posts: 4
I will try this thanks


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.