Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Mapping a link DB table in hibernate

 
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
 
Ranch Hand
Posts: 662
Eclipse IDE Spring Java
  • 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.
 
Your mother is a hamster and your father smells of tiny ads!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic