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.
|