you shouldn't need to run another select
you should find the id of the Dictionary class populated with the generated
key after running the insert
LiborP wrote:
>
> Hi all,
> I'm new in iBatis. I'm using Swing, Spring, iBatis and Apache Derby in my
> desktop project. I'm struggling with receive inserted ID. I'm not able to
> find out last inserted ID. To generate new ID I'm using Derby function
> IDENTITY_VAL_LOCAL(). This function works fine for generating ID. This is
> snipped of relevant code:
> <insert id="insertDictionary" parameterClass="Dictionary" >
> insert into Dictionary ( id, word, value, description, idLesson)
> values ( DEFAULT,
> #key#, #translation#, #description# ,#idLesson# )
>
> <selectKey keyProperty="id" type="pre" resultClass="int">
> values IDENTITY_VAL_LOCAL()
> </selectKey>
> </insert>
> DAO snipped:
> return getSqlMapClientTemplate().insert("Dictionary.insertDictionary",
> dictionary);
> I tried to create another select to get last inserted ID like this:
> <select id="lastInsertedID" resultClass="Integer">
> values IDENTITY_VAL_LOCAL()
> </select>
> but it returns null as well. I tried to use "values IDENTITY_VAL_LOCAL()"
> in SQL client and it works fine.
> I'm not using transactions. iBatis version 2.3.4.726, Derby version
> 10.4.1.3. Can anybody help please?
>
--
View this message in context:
http://www.nabble.com/Obtain-generated-ID-tp21372327p21387974.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.