| Author |
Many to One instead of One to One relationship
|
Rahul Babbar
Ranch Hand
Joined: Jun 28, 2008
Posts: 210
|
|
Hi All,
I have two tables in the database which have a one to one relationship between them.
However when i generate the annotated POJOs using Netbeans IDE, a many to one is generated instead of One to One.
Here are the database script.
Because of some complexities, i cannot make A_ID as the primary key in the table B.
So, A_ID is made the unique key and is made not null and unique and then joined with A.
Here are the Pojos that are generated.
Why is a Many To One generated instead of one to one.
I dont really need B or Set of Bs in A, so i can remove it in A.
However in B, i would have preferred One to One with A(although it is almost the same as Many to One with A_Id being unique and not null).
Can somebody help me out on that.
Thank you
|
Rahul Babbar
|
 |
James Sutherland
Ranch Hand
Joined: Oct 01, 2007
Posts: 550
|
|
Object models and data models are very different things. Any object model from data model generator is just going to give you one of the possible objects models for the data model. It just see the constraint so guesses it is a ManyToOne. If you want it to be a OneToOne then just change the generated code. The code is just meant to get you started, normally you would want to design a proper object model based on your application requirements.
|
TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
|
 |
Rahul Babbar
Ranch Hand
Joined: Jun 28, 2008
Posts: 210
|
|
|
Thanks James.
|
 |
 |
|
|
subject: Many to One instead of One to One relationship
|
|
|