Hibernate annotations one to many relationship with composite primary key
posted 5 years ago
First of all, kindly look at my design,
I have two tables
T1(a,b,c,d)- a is primary key
T2(a,e) where (a,e) is composite primary key
a is the foreign key referencing T1(a)
T1 - T2 relationship is one to many.
So I created three classes
1. C1 for T1
It has five fields -
a,b,c,d, c2Set with setters & getters
2. C2 for T2
It has two fields- c1,c3 of type C1, C3 respectively- with setters & getters
3. C3 I am defining C3 to represent composite primary key of T2
It has two fields (a,e) with setters & getters
I am using following annotations to define hibernate mappings in classes C1,C2,C3 respectively
I have a problem when I am inserting(saving) data. Data into T1 is getting inserted but no insertion is happening in T2( which I think should happen automatically here) ?
Please tell me where I am doing things wrongly.
And, I want to learn more about Hibernate Annotations. Can anyone point me to some useful online resources.
And, is it good to separate a form bean from entity class?
Please tell me the resources where I can get to learn about design issues like this.