Try this (insert instead of update):
return getSqlMapClientTemplate().insert("insert" +
object.getClass().getSimpleName(),object);
Darek
----- Original Message -----
From: "Koka" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Friday, August 05, 2005 7:32 AM
Subject: Trouble with oracle 10g selectKey
Wow, seems I'm dumb-minded today, can not make selectKey work....
Following the SQL-Maps-2.pdf I have:
<insert id='insertService' parameterClass='service'>
<selectKey resultClass='int'>
select services_seq.nextval as service_id from dual
</selectKey>
insert into Services ( service_id,service_name)
values ( #service_id#,#service_name#)
</insert>
and dao (I'm using spring) looks like
public class ObjectDao extends SqlMapClientDaoSupport
public int insertObject(Object object) throws DataAccessException
{
// Service service = (Service) object;
// if (service.getService_id() == 0)
// {
// service.setService_id(((Integer) //
//
getSqlMapClientTemplate().queryForObject("getServiceSeq",0)).intValue());
// }
return getSqlMapClientTemplate().update("insert" +
object.getClass().getSimpleName(),object);
}
It tries to insert '0' for service_id. However all works fine if I
uncomment those commented lines where I select sequence manually and
omit the selectKey from sql-map
Can someone indicate any direction where I should look?
TYA
Nicholoz Koka Kiknadze