ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steven Pannell <steven.pann...@zooplus.com>
Subject RE: Getting the generate primary key
Date Thu, 17 Mar 2005 16:08:20 GMT

Yes, that's right.  Not a good idea to use max(id) in oracle at all.

-----Original Message-----
From: Akins, Greg [mailto:gakins@amervideo.com]
Sent: 17 March 2005 17:08
To: ibatis-user-java@incubator.apache.org
Subject: RE: Getting the generate primary key

In Oracle, is that going to be difficult if you're using a trigger to
create the ID?

Using a select from sequence insure that you have the same ID as the
insert statement is going to receive.

Using @@identiy and select Last_insert_id() guarantee (I think) that the
value returned was the one used by your insert statement.

However, in Oracle, you'll have to select the max(id) after the insert
and there is no guarantee that you're getting the same id, right?

-----Original Message-----
From: James, Steven [mailto:Steven.James@logicacmg.com] 
Sent: Thursday, March 17, 2005 11:03 AM
To: ibatis-user-java@incubator.apache.org
Subject: RE: Getting the generate primary key

you need to add the 
<selectKey resultClass="int" keyProperty="id" > 
			select LAST_INSERT_ID()  
above is for mysql just change to olacle specific code. etc


-----Original Message-----
From: Steven Pannell [mailto:steven.pannell@zooplus.com]
Sent: Thu 3/17/2005 3:52 PM
To: 'ibatis-user-java@incubator.apache.org'
Subject: Getting the generate primary key

I want to get the automatically generated key from a newly inserted row
(my oracle database handles the generation of the key via a trigger).  

I followed the docs but it does not appear to be working.


<insert id="writeOrder" parameterClass="Order"  >


Long id = (Long)client.insert(new SqlMapId("writeOrder"),order);

The returned value is always null. but I want the primary key id.

am I doing anything wrong here (using ibatis  I'm sure when i
tried this on an earlier version if iBatis it was working.


View raw message