-->
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.  [ 4 posts ] 
Author Message
 Post subject: Distributed enviroments - best practices
PostPosted: Fri Mar 17, 2006 5:21 pm 
Newbie

Joined: Fri Jan 20, 2006 1:32 pm
Posts: 11
Hi,
is there any set of best practices how to use hibernate in distributed enviroments (WS,RMI etc.)?

For exmaple:
class Parent
Set childrens;

User gets a long list of Parents but he clicks maybe 3 or 4 of them during his work with application.
So it's a waste of memory to load all childrens(lazy="false" or Hibernate.initialize(childrens) for instance)...
But when the application is distributed over the Internet then user have to wait after clicking the parent to get childrens
(it's even the same story with parents - load whole objects to get the procedure 'View detail' faster
or load only the names for viewing in list of parents - but make user wait after calling 'View detail' to load data)?

Thank you


Top
 Profile  
 
 Post subject: 2c
PostPosted: Fri Mar 17, 2006 7:11 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
My take is this: never ever use Lazy=”true” for distributed environment.
The situation with list of objects:
well, there should not be “objects”, the list should contain briefs about real objects, the real ones should be instantiated when user makes choice – click on one.

Unfortunately Hibernate does not support auto conversion of a result set into a list of maps, and does not support using naming conventions to call setters on objects, although Max wants to add it at some point. Therefore there are options:
create separate mapping for lightweight objects (or maps);
use native query support and map result sets to list of arrays;
supplement Hibernate with direct JDBC;
supplement Hibernate with iBatis;

Note: if you use master-details relationships then Hibernate uses own implementation of collection interfaces, therefore in case of RMI client should have hibernate.jar in its classpath.
Or Hibernate collections has to be replaced with Java standard ones like this:
parent.setChildren( new ArrayList( parent.getChildren()));

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

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 18, 2006 4:02 am 
Newbie

Joined: Fri Jan 20, 2006 1:32 pm
Posts: 11
So the working solution can be to create lightweight object ParentSmall (name,surname,age)
to make it faster when user clicks it in the list to view the brief information(ParentSmall is loaded locally - but what if I have 50 thousand of them in database?)
and real Parent object (ParentSmall+address,childrens) which is full-value object (user clicks 'full info' for instance)
which will be loaded on demand?

And lazy="false" everywhere?

Quote:
Note: if you use master-details relationships then Hibernate uses own implementation of collection interfaces, therefore in case of RMI client should have hibernate.jar in its classpath.
Or Hibernate collections has to be replaced with Java standard ones like this:
parent.setChildren( new ArrayList( parent.getChildren()));

What's the preffered approach? Is it only about the time to download client (with/out hibernate.jar) or is there any other complication?
now I have to have hibernate.jar in client classpath...

Thank you


Top
 Profile  
 
 Post subject: techniques
PostPosted: Sun Mar 19, 2006 2:56 am 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
Time to download hibernate.jar on client is the only concern.
ParentSmall and ParentFull might be entity names in the mappings and employ the same class, or they can be separate classes
For the list use "from ParentSmall where ...."
When client will need ParentFull then the retrieval of the object will happens in a separate H session where you can employ method like session.get( ParentFull.class, id); so no problems are expected
and then you need to make sure that object is fully initialized before sending it over the wire.
http://www.hibernate.org/hib_docs/v3/re ... e-fetching

_________________
--------------
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.  [ 4 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.