-->
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.  [ 5 posts ] 
Author Message
 Post subject: Mapping across 1-1 table with no primary key in 2nd table
PostPosted: Tue Jul 20, 2004 7:42 am 
Newbie

Joined: Tue Jul 20, 2004 7:32 am
Posts: 3
Hello,

I'm new to hibernate and am fast becoming a big fan. I have just convinced a a client to use it after a big POC shootout between toplink, JDO and Hibernate.

Now I have questions!

The project is an oracle 9i database that we have little control over. There are two tables in the db which should be one, but legacy architecture does not permit this.

The tables are connected via a 1-1 link and there is no primary key in the second table. The tables are only ever updated using a join.

I have considered using the foreign key in the second table as the primary, then using the assigned generator to populate it by pulling back the primary key from the first. Although this seems a very messy solution.

I notice in the CVS log that mutiple table mapping across one class using a join has been made possible although I can not find any documentation or discussion on this.

Any help or otehr solutions would be most gratefully appreciated.

Many Thanks for a great product,
F.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 20, 2004 9:14 am 
Newbie

Joined: Wed Jul 14, 2004 9:20 am
Posts: 4
well, if you don't mind the two tables mapping to two different hibernate classes with a one-to-one association I think section 5.1.11 (primary key association) of the online HTML documentation should be able to give you what you need. It describes how to use ids of type "foreign."

Josh


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 20, 2004 10:56 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
I'm pretty sure that the ability to map a class across multiple tables is only targetted for hibernate3 with no plans to backport it to hibernate2. But I may be incorrect there. At any rate, it would still have the same limitations as the one-to-one mapping.

Just to understand better, you have two tables which logically represent a one-to-one relationship but semantcially implement a one-to-many relationship (the many side having an fk back to the one side's pk)? If thats the case, just use the one-to-one mapping using the property-ref attribute. Check out the docs regarding "unique foreign key associations" under http://www.hibernate.org/hib_docs/reference/en/html/mapping.html#mapping-declaration-onetoone


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 20, 2004 11:08 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
We *may* backport the new ClassPersister heirarchy from the current 3.0 branch to the 2.1 branch, once we are satisfied that it is stable in CVS. But no promises.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 20, 2004 11:40 am 
Newbie

Joined: Tue Jul 20, 2004 7:32 am
Posts: 3
Thank you all for your speedy and helpful replies.

Steve you have my problem correct apart from there being no pk in the secondary table, so I cannot use the fk, unique="true" solution.

Am I right in thinking that if I use the foreign id generator solution on the fk in the secondary table it should work anyhow?


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