File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "One to many insert with iBatis" Watch "One to many insert with iBatis" New topic

One to many insert with iBatis

Hussein Baghdadi
clojure forum advocate

Joined: Nov 08, 2003
Posts: 3479

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:
subject: One to many insert with iBatis
It's not a secret anymore!