Win a copy of Murach's MySQL this week in the JDBC and Relational Databases 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 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

One to many insert with iBatis

 
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
reply
    Bookmark Topic Watch Topic
  • New Topic