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: Hibernate Relationship Mapping Problem
PostPosted: Mon Mar 02, 2009 10:49 am 
Newbie

Joined: Fri Feb 20, 2009 6:25 am
Posts: 10
Hi all,

I have one issue in dealing with Hibernate associations. I just wanted to know that is there any drawback of using Associations by Hibernate mapping file? One of my senior is saying that there will be a lot of performance problems in using associations by Hibernate.

Other approach is to use Seperate mapping class that corresponds to the table for the mapping. And map this class as our persistent class in the mapping file, argument is that we will not need to jump into the hotch potch of Lazy loading and sets and lists. Is this the right approach to deal with relationships between classes?

I just want to know your openions. It would be better if you can explain it with logical arguments and examples.

_________________
Thanks & Regards,

Vishal Shukla


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 02, 2009 1:01 pm 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
Well, in my opinion it is even better to use associations in hibernate. If I understand you right, the other solution would be to manage all foreign keys manually, e.g. having an attribute foreign_id as long instead of an object-type attribute.

The good thing about using associations is, that you hibernate is able to manage all things about foreign keys and loading. Of course, you have to do the right config and usage to get performance gains, but if you use it right, it's going to be way faster than without it. For example with a simple HQL "from MyParent join fetch childs" you could retrieve all parents and their childs in a single statement. Doing it manually you would probably select parents first and then the childs of every single parent (n+1 select problem).

Consult the manual, there are several other examples of how to improve performance.

_________________
-----------------
Need advanced help? http://www.viada.eu


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.