-->
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.  [ 7 posts ] 
Author Message
 Post subject: Hibernate Association - How deep it should be for entr appln
PostPosted: Thu Sep 08, 2005 1:26 am 
Beginner
Beginner

Joined: Tue Aug 16, 2005 3:58 am
Posts: 40
Location: Singapore
Hi,
Can anyone suggest me how deep we can use and we should avoid the temptation of using Association in Hibernate in enterprise applns?

Say for ex, Product -> Purchase -> PurchaseDetails ->Settlements

In this chain of objects, is it advisable to implement association using Hibernate to this longer or limit it to just Purchase -> PurchaseDetails, as it is this which we may need to look for very often in report prepration etc? Or implement all links so that I could get settlements details by using
following code:

product.getPurchases().getPurchaseDetails(<xxx>).getSettlements()

Your kind reply is highly appreciated.

Regards,
Aru K


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 08, 2005 1:39 am 
Beginner
Beginner

Joined: Tue Aug 16, 2005 3:58 am
Posts: 40
Location: Singapore
Or is it good design to implement association for every foreign-key relatioships????


For ex, teacher and examination relational tables, in whch examination has a field say Supervisor which refers the teacher tables ID. For this schenario, do I need to implement association using Teacher object in Examination or just go with having declaring a Long variable for teacher's ID in Examination object????

Which one is better option???


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 08, 2005 1:49 am 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
arumugam_kasi wrote:
is it good design to implement association for every foreign-key relatioships????


Sure.

arumugam_kasi wrote:
implement association using Teacher object in Examination


Yes.

arumugam_kasi wrote:
or just go with having declaring a Long variable for teacher's ID in Examination object????


No.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 08, 2005 1:59 am 
Beginner
Beginner

Joined: Tue Aug 16, 2005 3:58 am
Posts: 40
Location: Singapore
One more question on the same subject.

Will it not affect the performance of the system (by taking account of large number of concurrent users) for the case of updating an Exam object in the case of having an association betn Exam and Teacher objects?

ie, even for mere update of teacher ID in Exam table, I need to load new Teacher Object and assign it to Exam's ID field and update Exam object.

As you know, somehow we would know teacher's ID before calling the function to update Exam object. Why should not we just directly supply the ID to Exam and update there.

If it is of Purchase ->PurchaseDetails, we could clearly see the strong relationship which would be enough to justify the Association, but I dont know if I m missing any important piece, why should I really care about association for the weaker case (in-frequently used one too)?

Thanks in advance for your reply!!!!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 08, 2005 2:00 am 
Beginner
Beginner

Joined: Tue Aug 16, 2005 3:58 am
Posts: 40
Location: Singapore
One more question on the same subject.

Will it not affect the performance of the system (by taking account of large number of concurrent users) for the case of updating an Exam object in the case of having an association betn Exam and Teacher objects?

ie, even for mere update of teacher ID in Exam table, I need to load new Teacher Object and assign it to Exam's ID field and update Exam object.

As you know, somehow we would know teacher's ID before calling the function to update Exam object. Why should not we just directly supply the ID to Exam and update there.

If it is of Purchase ->PurchaseDetails relation, where we could clearly see the strong relationship which would be enough to justify the Association, but I dont know if I m missing any important piece, why should I really care about association for the weaker case (in-frequently used one too)?

Thanks in advance for your reply!!!!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 08, 2005 2:20 am 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
arumugam_kasi wrote:
Will it not affect the performance of the system (by taking account of large number of concurrent users) for the case of updating an Exam object in the case of having an association betn Exam and Teacher objects?


See the documentation on the differences between lazy and eager loading.

arumugam_kasi wrote:
ie, even for mere update of teacher ID in Exam table, I need to load new Teacher Object and assign it to Exam's ID field and update Exam object.


This depends on how many simultaneous users want to update Teachers and Exams .

arumugam_kasi wrote:
As you know, somehow we would know teacher's ID before calling the function to update Exam object. Why should not we just directly supply the ID to Exam and update there.


My users have never noticed a time lag; my project manager has noticed time saved.

arumugam_kasi wrote:
If it is of Purchase ->PurchaseDetails relation, where we could clearly see the strong relationship which would be enough to justify the Association, but I dont know if I m missing any important piece, why should I really care about association for the weaker case (in-frequently used one too)?


Eager vs. lazy loading.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 08, 2005 2:24 am 
Beginner
Beginner

Joined: Tue Aug 16, 2005 3:58 am
Posts: 40
Location: Singapore
Hi,
Thanks friend for your comments. They really helped a lot to clear off few important things.

Regards,
Aru K


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