ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James, Steven" <Steven.Ja...@logicacmg.com>
Subject RE: Getting the generate primary key
Date Thu, 17 Mar 2005 16:02:32 GMT
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: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
 
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.



This e-mail and any attachment is for authorised use by the intended recipient(s) only. It
may contain proprietary material, confidential information and/or be subject to legal privilege.
It should not be copied, disclosed to, retained or used by, any other party. If you are not
an intended recipient then please promptly delete this e-mail and any attachment and all copies
and inform the sender. Thank you.
Mime
View raw message