-->
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.  [ 1 post ] 
Author Message
 Post subject: Mapping of a phys.l 1:n onto a logical 1:1 relation possbl.?
PostPosted: Fri Apr 25, 2008 8:19 am 
Newbie

Joined: Fri Apr 25, 2008 7:21 am
Posts: 1
Hello!

We are currently using Hibernate 3.2.4.

We have the following mapping question:

We have three objects types/tables:

Type A: Some business object
Type B: Some depending business object
Type C: Some table that defines time slices.

A, B and C have normal primary keys, A and B also have logical keys that mark object of some logical indentity for different time slices.
C defines time slices. Objects of B (and also of A, but that is out of scope for this question) with different primary key and the same logical key point to different time slices and in fact one row of B can even have multiple assigned time slices, so that there is a "one to many" relation between B and C, too.

As a result A and B have a "1 to many" relation if joining over this logical key. Rows in A point to multiple rows in B since there are different matching rows in B depending on the time slice defined by C ( C contains entries with an "from" date and an additional optional "to" date).

However while the table layout defines a "1 to many" relation between A and B and B and C in our application infact there is always logically a one two one relation between A and B because there is exactly one row in B that matches a row in A *at one point of time*. Selects over A and B (and C) will always contain an additional WHERE criterium that selects exactly one row in B (via a join to C).

The problem: If we model the mapping to define a "one to one" relation, hibernate may get problems when the WHERE is left out accidently. However if we map a "one to many" relation we need to define a Collection type in the java objects for table A - which is ugly on the java side.

Currently our code defines no realtion between the table at all and loads depending instance of B manually - which is ugly. Also its seems like using DetachedCriteria one cannot define a join over A and B, since hibernate cannot see the relation looking at the mappings. And DetachedCriteria are nice :-)

Is there a way to write some mapping that allows us to map the physical :n relation onto a 1:1 relation and a additional WHERE criterium? Or are there nay features in hibernate to help us smooth the java side.

Any hint to some code or documention fragment and a general solution strategie would be helpful.

Thanks for any help!

Gruß...Tim

_________________
Gruß...
Tim


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.