File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Mapping a link DB table in hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Mapping a link DB table in hibernate" Watch "Mapping a link DB table in hibernate" New topic
Author

Mapping a link DB table in hibernate

Nischal Tanna
Ranch Hand

Joined: Aug 19, 2003
Posts: 182
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


Thnx
Arun Kumarr
Ranch Hand

Joined: May 16, 2005
Posts: 513

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.


If you are not laughing at yourself, then you just didn't get the joke.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Mapping a link DB table in hibernate