-->
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: What is a better approach? - A mapping design question
PostPosted: Thu Jun 09, 2005 6:28 pm 
Regular
Regular

Joined: Wed Aug 25, 2004 7:40 pm
Posts: 65
Here is the situation I have:

The class A has a many-to-one relationship with the class B, while the class B has another many-to-one relationship with the class C. The class B refers the class C by object.

A main DB operation on the class A, other than saving, is retrieving all object with a HQL, somthing like "from A order by b, another-attribute". With a business logic ooperation, an object of the class C may need.

Shall I hava the class B referred in the class A by id or object? The by-object approach is convenient. But, I guess there are some performance penalty with this approach. The operation stated above will be perform periodically every hour. And the number of records can be large.

Thanks for your inputs.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 10, 2005 4:42 am 
Beginner
Beginner

Joined: Mon Apr 11, 2005 8:37 am
Posts: 22
Is performance really influenced when using by-object references? I can't see a reason for it - no matter whether you use select-fetching or join-fetching for your object B (from A). In SQL the join is always done by id. And the full object B must be retrieved anyway (or just the columns you define). I may be wrong - can anybody confirm it? Or is there an aspect I don't see at the moment? I'm just interested.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 10, 2005 12:40 pm 
Regular
Regular

Joined: Wed Aug 25, 2004 7:40 pm
Posts: 65
Thanks for your input.

Whether objects of the class B in addition of objects of the class C are needed or not is up to the business logic of the application. They are not needed every single time.

The reason I rise the performance concern in this case is there are more than just SQL join operation. If I use the reference by object approach, for every single class A object retrieved, an object of the class B and an object of the class C are also created. There is a lot of object creation in comparsion of the reference by id approach. Object creation is expensive.

It is my first time using Hiberate. I would like to learn others' experience in this regard.


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.