-->
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: many-to-one relationship with two tables but only one class
PostPosted: Fri Mar 30, 2007 5:06 pm 
Newbie

Joined: Fri Mar 30, 2007 4:54 pm
Posts: 1
I have one class:

Car {
- id:int
...
- color:String
}

And two tables storing the information:

CAR [
ID:INTEGER (PK)
...
COLOR_ID:INTEGER (FK)
]

COLOR [
ID:INTEGER (PK)
NAME:STRING
]

I've been trying to map the Car class to both tables, without any success.

First i tried it with a <join>, but it'd only work if a had the foreign key in the COLOR table, refering to the primary key of CAR (and i have it the other way around: the CAR fk refering to the COLOR pk).

Then i tried with the <many-to-one>, but Hibernate requires two classes for it, Car and Color.

Does anybody know how to do it without changing the classes and the tables?

Thanks a lot,

Luiz.


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.