-->
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: Non-typical relationship between tables and entities
PostPosted: Mon May 25, 2009 9:39 am 
Newbie

Joined: Mon May 25, 2009 9:27 am
Posts: 1
Hi everyone,

I have a table (let's call it addresses) in DB with complex (double) primary key. It looks like that:
(_id_, _version_, sth...)
When I update an entity, my DAO creates new row in database with the same id and newer version.
So, all rows with same id, are various versions of the same entity.

I have relationship from another table (let's call it persons). But this relationship says, that only newest versions of addresses are interested. There is only one foreign key column "address_id". When I get something from table "persons" i want to join address with a subquery (where version = (select max(version) from addresses where id = ID)).

Is it possible to map hibernate ManyToOne or OneToOne relationship like that?

Or maybe I should change my data model?

Thanks for answers.


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.