• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Mapping a link DB table in hibernate

 
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 662
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic