ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Darek Dober" <doover...@op.pl>
Subject Re: Trouble with oracle 10g selectKey
Date Sat, 06 Aug 2005 04:38:03 GMT
Try this (insert instead of update):

return getSqlMapClientTemplate().insert("insert" +


----- Original Message ----- 
From: "Koka" <226057@gmail.com>
To: <user-java@ibatis.apache.org>
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
insert into Services ( service_id,service_name)
values ( #service_id#,#service_name#)

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) //
//        }

        return getSqlMapClientTemplate().update("insert" +


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?
Nicholoz Koka Kiknadze

View raw message