-->
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.  [ 6 posts ] 
Author Message
 Post subject: Strategy for passing persistent objects to the front
PostPosted: Tue Dec 05, 2006 6:04 am 
Newbie

Joined: Mon Dec 04, 2006 12:06 pm
Posts: 4
Hi there,
i would like to ask you what would be the best approach to pass hibernate persistent objects, that might contain Collections, from the back to the front.
Considering that the front "does not know" hibernate, is there any other solution than converting the persistent objects to Dtos, creating then another layer of abstraction ?

Thank you in advance,
Thiago


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 07, 2006 5:44 pm 
Newbie

Joined: Tue Nov 07, 2006 5:06 pm
Posts: 13
Don't create another layer of abstraction, that's just a waste. Entity objects actually "don't know" about Hibernate either, so using them in the 'front' or presentation layer will not couple the presentation to the 'back' layer or persistence (Hibernate).


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 12, 2006 10:38 am 
Newbie

Joined: Mon Dec 04, 2006 12:06 pm
Posts: 4
What about Collections such as Set ?
I've heard that is not a good idea to pass Hibernate Collections to the front because they are attached to a hibernate session.

What you think of that ?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 12, 2006 10:46 am 
Regular
Regular

Joined: Wed Mar 23, 2005 8:43 am
Posts: 105
Location: Moscow, Russia
You can transfer Domain Objects instead of DTO by network between layers, but in this case you must fully initialize properties of your Domain Objects, because if you try to acces proxy outside the Hibernete Session, you recive LazyInitializationException.

You can use fetch join in HQL and Criteria API or Hibernate.initialize() inside Hibernate Session for that.

_________________
Best Regards


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 12, 2006 10:56 am 
Newbie

Joined: Mon Dec 04, 2006 12:06 pm
Posts: 4
I aggree with you.
My problem is that my hibernate objects have Sets that are quitte expensive in terms of data. If i have to full initialize them, i guess it might be a considerable cost to the memory and/or to the network.
Does it make sense ?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 12, 2006 11:05 am 
Regular
Regular

Joined: Wed Mar 23, 2005 8:43 am
Posts: 105
Location: Moscow, Russia
Yes, you're right. So you need to initialize only that associations, that you'll need on the other tier. Other associations must be leaved lazy.

_________________
Best Regards


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