Is it possible that in your ibatis application, the insert statement and
the 'values IDENTITY....' statement are executed on different connections.



                                                                           
             LiborP                                                        
             <liborpre...@sezn                                             
             am.cz>                                                     To 
                                       [email protected]         
             09/01/2009 18:59                                           cc 
                                                                           
                                                                   Subject 
             Please respond to         Obtain generated ID                 
             user-j...@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.



Reply via email to