Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mapping a link DB table in hibernate

 
Nischal Tanna
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All
Supposed i have a table student which has fields as:

student_id number - this is the primary key
student_name varchar
student_surname varchar

A table student_rel which is the relational table is as:

student_rel_id - this is the primary key
student_id - this refers the above primary key

Table student_details as follows:

address_id
student_rel_id - mapped from above
address

Pls dont tell me to change the db design as its an existing one ...
My question is whether it is possible to tell hibernate to automatically do things as below on insertion in the student table:

1. hibernate should automatically insert into the relational table student_rel
2. Fetch the student_rel_id after generation from step 2 and insert this along with the address in address table
 
Arun Kumarr
Ranch Hand
Posts: 661
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Nischal Tanna:

My question is whether it is possible to tell hibernate to automatically do things as below on insertion in the student table:

1. hibernate should automatically insert into the relational table student_rel
2. Fetch the student_rel_id after generation from step 2 and insert this along with the address in address table


- Yes. You can.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic