-->
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: How to detect a mapped collections initialization state ?
PostPosted: Fri Oct 07, 2005 3:46 pm 
Newbie

Joined: Wed Feb 16, 2005 4:54 pm
Posts: 1
Hibernate version: 3.0.5

I have an persistent object with mapped collections.

SalesTransaction
SalesTransactionItems
SalesTransactionPayments

The items and payments are lazy initialized, and I use Hibernate.initialize in my DAO's for the instances where the view is going to need the item/payment details.

My problem comes in debugging, and the toString method of SalesTransaction.

I am looking for some way to detect if the mapped collections of my now detached SalesTransaction are initialized or not.

If they are, I can include their details in the toString, and the log, otherwise I want to stay away from them with a 10ft pole to prevent the expected LazyInitializationException.

The only solution I have come up with is to subclass SalesTransaction with a SalesTransactionFull what would always have the collections initialized and a different toString, but it seems a PITA just so I have some more detail in my debug logs..


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 07, 2005 6:15 pm 
Newbie

Joined: Wed Mar 30, 2005 8:58 am
Posts: 10
Location: São Paulo / Brazil
Check the API again, where you have found the Hibernate.initialize(Object) method. In the same class, there is a method called isInitialized(Object).

:)

[]'s

_________________
www.brunoborges.com.br


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.