-->
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 get pure POJO for webservice purpose
PostPosted: Thu Nov 10, 2005 9:45 am 
Newbie

Joined: Thu Sep 15, 2005 2:29 am
Posts: 3
We have been struggle to make webservice work with Hibernate without defining any additional DTO. We want to leverage our Hibernate business object/value object.

However, since we do use lazy inflate feature of hibernate, therefore, it always return proxy which is a subclass of the POJO. The problem with that is the LazyInitializationException once it is out of the session. By the time we use it out of session, we want to treat it as a pure POJO.

We use weblogic webservice implementation. It will introspect our proxy for all the getter and setter methods. This obviously happens outside of session. Due to outside session, WebLogic webservice is complaining getting LazyInitializationException before make the webservice communication. That is why our webservice do not work with hibernate POJO at all as long as the whole object graph is not fully inflated.

Have anyone found any solution for that yet? I think you will run into the similar problem by passing hibernate POJO for webservice.

Defining another layer of DTO is also annoying. Then you need to deal with copy POJO to DTO, which can be very difficult when you have cyclic reference.

Please advise. Thanks.


Hibernate version: 3.0.5


Top
 Profile  
 
 Post subject: initialize
PostPosted: Fri Nov 11, 2005 12:04 am 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
This may help::
http://www.hibernate.org/hib_docs/refer ... mance.html
Quote:
The static methods Hibernate.initialize() and Hibernate.isInitialized() provide the application with a convenient way of working with lazyily initialized collections or proxies. Hibernate.initialize(cat) will force the initialization of a proxy, cat, as long as its Session is still open. Hibernate.initialize( cat.getKittens() ) has a similar effect for the collection of kittens.


Also as you need all the fields initialized for WS anyway you may just specify lazy=false

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


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.