• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mapping of three tables

 
Ankit Chandrawat
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a mapping problem that i need to explain through table structures.

I have mapped all three tables to their respective POJOs. Table1.java Table2.java and Table3.java
Table1 and table3 share 1:1 relationship that i am doing by using <one-to-one> and it is getting mapped successfully as I get the object of type Type3.java inside the object of Type1.java when database call is completed.
Between Table3 (id_session) and Table2 is (id_session) I am trying to establish a many-to-one relationship. So, in this way with an Object of Type1.java, I would be able to access Type2.java through object of Type3.java. How can I achieve this ?


TIA,
Ankit
 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In JPA you would just define an @ManyToOne (<many-to-one>) relationship in Type3 using "id_session" as the @JoinColumn (<join-column>.

See,
http://en.wikibooks.org/wiki/Java_Persistence/ManyToOne
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic