ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mario Ds Briggs <mario.bri...@in.ibm.com>
Subject Re: Obtain generated ID
Date Fri, 09 Jan 2009 18:40:46 GMT
Is it possible that in your ibatis application, the insert statement and
the 'values IDENTITY....' statement are executed on different connections.



                                                                           
             LiborP                                                        
             <liborprenek@sezn                                             
             am.cz>                                                     To 
                                       user-java@ibatis.apache.org         
             09/01/2009 18:59                                           cc 
                                                                           
                                                                   Subject 
             Please respond to         Obtain generated ID                 
             user-java@ibatis.                                             
                apache.org                                                 
                                                                           
                                                                           
                                                                           
                                                                           





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-tp21372327p21372327.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.




Mime
View raw message