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:[EMAIL PROTECTED] Sent: Thursday, March 17, 2005 10:08 AM To: [email protected] 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:[EMAIL PROTECTED] Sent: Thursday, March 17, 2005 11:03 AM To: [email protected] Subject: RE: Getting the generate primary key you need to add the <selectKey resultClass="int" keyProperty="id" > select LAST_INSERT_ID() </selectKey> above is for mysql just change to olacle specific code. etc steve -----Original Message----- From: Steven Pannell [mailto:[EMAIL PROTECTED] Sent: Thu 3/17/2005 3:52 PM To: '[email protected]' Subject: Getting the generate primary key Hi, 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. SqlMap: <insert id="writeOrder" parameterClass="Order" > INSERT INTO ORDERS(order_price) values(#orderPrice#) </insert> Code: 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 2.0.9.496) I'm sure when i tried this on an earlier version if iBatis it was working. Thanks, Steve.

