• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

Hibernate annotations one to many relationship with composite primary key

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everybody,

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

1.


2.




3.









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.

Thanks
Vivek.


 
Seriously? That's what you're going with? I prefer this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!