wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes One to many insert with iBatis Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "One to many insert with iBatis" Watch "One to many insert with iBatis" New topic
Author

One to many insert with iBatis

Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3476

Hi.
Consider these two tables: Order and OrderItem.
The relationship is one to many.
To save an order, two SQL command should be executed:
Insert a row in Order table (ORDER_ID is auto generated).
Insert a row in OrderItem table (OI_ID is auto generated and the primary key of the previous insert is needed in this command).
I'm trying to adopt iBatis and MySQL as the database.
The problem is I don't know how to get the PK of the first row in order to be passed to the second row?
Any ideas?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: One to many insert with iBatis
 
Similar Threads
Hibernate - id column of an entity as list-index column in another entity?
hibernate saving multiple hierarchy records
oracle sequence id
ejb 1.1 how to using ejb about one to many relationship?
Null Value in @JoinColumn