-->
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: Hibernate Performance
PostPosted: Thu Dec 06, 2007 11:23 pm 
Newbie

Joined: Sat May 19, 2007 10:50 pm
Posts: 4
Hibernate version:3.2.5



Hi,

Here is a scenario while integrating the Hibernate and its performance

1. I have 8 tables one Master table and 7 child tables. I generated a hbm file that contains link to all the tables as per the database.
2. hbm file is created using the tool in the eclipse
3. POJO objects are created basing on the database design. Master POJO and in that we have objects of all the other 7 tables
4. I do have 8 select queries that execute on above 8 table. In which
Query 1 – Will retrieve information from table 1 & table 2
Query 2 – Will retrieve information from table 1, table 2 and table 3
Query 3 – Will retrieve information from table 1, table 3 and table 4
Query 4 – Will retrieve information from table 1, table 4 and table 5
Query 5 – Will retrieve information from table 1, table 2, table 3 and table 4
Query 6 – Will retrieve information from table 1, table 2, table 3, table 4, table 5, table 6, table 7, table 8
Query 7 – Will retrieve information from table 1, table 2, table 6, table 7, table 8
Query 8 – Will retrieve information from table 1, table 7, table 8


Now the question is because by Master POJO contains links to all the object does hibernate loads all the objects in the memory irrespective of the query.

For example Query 1 is executed – In this I am trying to retrieve the values for two tables, but my Master POJO and its hbm file contains link to all the tables. So does that mean it will load the content for the rest of the tables even though I am not querying it in the same query.

If so what would be the best approach for all the above queries that to be followed in the hibernate.


Thanks
Badri


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 07, 2007 2:58 am 
Expert
Expert

Joined: Thu May 26, 2005 9:19 am
Posts: 262
Location: Oak Creek, WI
Hi,

Try to lazy load the data for the rest of the objects in MasterPOJO, if you dont need it.

_________________
RamnathN
Senior Software Engineer
http://www.linkedin.com/in/ramnathn
Don't forget to rate.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 07, 2007 3:07 am 
Regular
Regular

Joined: Mon Mar 26, 2007 12:38 am
Posts: 119
Hi,
>>Now the question is because by Master POJO contains links to all the object does hibernate loads all the objects in the memory irrespective of the query.
It depends on the configuration.
Hibernate is very flexible in terms of fetching associations. We specify,
i) When to fetch. ( initially or later when required )
ii) How to fetch. ( an outer join or select )
Please refer to http://www.hibernate.org/hib_docs/refer ... mance.html

>>If so what would be the best approach for all the above queries that to be followed in the hibernate.
a difficult question to answer.
It's a good idea to explore different options ( join fetch , select fetch, subselect fetch, batch fetch, lazy fetch ) and pick the one that suits the best.

Hibernate provides us with a lot of options and does what we ask it to do.
Performance is ( to a large extent ) our responsibility.


Hibernate In Action & Java Persistence With Hibernate are both good books.

My apologies if this answer is too vague!

-------------------------------------------
Rate the reply if you find it helpful


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.