-->
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.  [ 3 posts ] 
Author Message
 Post subject: How to map this one-to-one relation to Hibernate
PostPosted: Tue Oct 26, 2004 8:56 am 
Newbie

Joined: Tue Oct 26, 2004 8:44 am
Posts: 2
Hi,

I've got to make the Hibernate mapping for an existing Oracle DB schema.
It contains a one-to-one relationship between the instances of the same type, however it's been done the way many-to-many relations are:

There's a table for the entity instances, let's call it ENTITY, it has an id field and several property fields. There's another table called ENTITY_REL which contains two fields for the two ends of the relation, so each of them is a foreign key if ENTITY's id field. ENTITY_REL has also some other properties.

Again this lineup looks like a basic many-to-many relation mapping however, I know it's one-to-one. I would like to know if it's possible to let Hibernate know, it's a one-to-one relation, i.e. to create the appropriate Hibernate mapping. I currently have a many-to-many mapping, but not too happy with it..

Regards,

Zoltan


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 26, 2004 1:56 pm 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
As I understand one-to-one relations doe's not exist in databases, if you have it then put all attributes to the same table (declare nullable attributes last to save space if it was designed for this reason) and create two views for it, you can map this stuff as components too.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 27, 2004 4:10 am 
Newbie

Joined: Tue Oct 26, 2004 8:44 am
Posts: 2
Hi,

I think I was unclear: the database schema is given (unmodifiable), and I have to act upon it. So what I'd like to know if it's possible to create a Hibernate mapping that handles this schema as a one-to-one relation

Regards,

Zoltan


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