ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Karl Schwaerzler <Thomas.Schwaerz...@student.uibk.ac.at>
Subject insert with id as return value
Date Tue, 04 Jul 2006 18:53:34 GMT


hello,

at inserting new rows to a table i'm used to get the priamry key value of 
the inserted row back.


to get the desired result for a table called "link" i did 
the folowing:


 	public Long insertLink(OdmLink link)
 	{
 		// select next key val
 		Long id = linkDao.getNextKey();
 		link.setId(id);
 		linkDao.insert(link);
 		return id;
 	}


and added this query for getting the next id from sequent:

<select id="getNextKey" resultClass="long">
    <!--  added: is there a better solution? -->
   select c108272dev.odm_link_counter.nextval from dual
</select>



this works as i expected, but i ask myself if abator has a better solution 
for this.


looking forward to getting hints about this
tom.

Mime
View raw message