-->
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: joining three tables without a linking entity
PostPosted: Wed Mar 12, 2014 4:46 am 
Newbie

Joined: Wed Mar 12, 2014 3:27 am
Posts: 3
Hello all,
I have a database with 3 tables. The main table is Contract, and it is joined with pairs of keys from two tables: Languages and Regions.
each pair is unique, but it is possible that one contract will have the following pair ids:
{ (1,1), (1,2), (2,1), (2,2) }
Today, the three tables are linked via a connecting entity called ContractLanguages. It contains a sequence id, and triplets of ids from the three tables.
However, in large enough contracts this causes a serious performance issue, as the hibernate environment creates a staggering amount of objects.
Therefore, we would like to remove this connecting entity, so that Contract will hold some collection of these pairs.

Our proposed solution: create an @embeddable class containing the Language and Region id's, and store them in the Contract entity.
The idea behind this is that there is a relatively small number of languages and regions.
We are assuming that hibernate manages a list of such pairs and does not create duplicates, therefore substantially reducing the amount of objects created.

However, we have the following questions:
1. Will this solution work? Will hibernate know to create the correct object?
2. Assuming the solution works (the link is created correctly), will hibernate optimize the object creation to stop creating duplicate objects?
3. If this solution does not work, how do we solve the problem mentioned above without a connecting entity?


Top
 Profile  
 
 Post subject: Re: joining three tables without a linking entity
PostPosted: Thu Mar 13, 2014 12:02 pm 
Newbie

Joined: Wed Mar 12, 2014 3:27 am
Posts: 3
I am bumping this. Hopefully, someone will be able to help me with this issue! :)


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.