ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rafiq, Adnan" <ara...@carreker.com>
Subject RE: Getting the generate primary key
Date Thu, 17 Mar 2005 16:11:55 GMT
We have always used the table-driven approach for generating keys (i.e. a
database table that provides the next id). I am currently comtemplating
moving to identity columns in MS SQL Server and let the database handle the
id generation.

Any pros and cons (apart from the usual portability concerns) with this
approach? Is performance, with SQL Server, acceptable when inserting
thousands of rows in this fashion?

-----Original Message-----
From: Akins, Greg [mailto:gakins@amervideo.com]
Sent: Thursday, March 17, 2005 10:08 AM
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