ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Koka <226...@gmail.com>
Subject Trouble with oracle 10g selectKey
Date Fri, 05 Aug 2005 14:32:29 GMT
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

Mime
View raw message