ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Möller <dcmoel...@gmx.de>
Subject RE: select Key not working giving error.
Date Thu, 12 Jul 2007 14:45:36 GMT
Hi,

I myself are using this kind of iBATIS config with a Sybase DB:

  <insert id="insertContact" parameterClass="contact">
    insert into CONTACT (PROP1, ...) values (#property1#, ...)
    <selectKey resultClass="long" type="post">
      select @@IDENTITY
    </selectKey>
  </insert>

"@@IDENTITY" is the Sybase way to retrieve the auto-incremented value of
the primary key column.

As you can see: There is no mapping of the resulting key to a property
of the parameter class. I'm retrieving the auto-incremented key by
executing

  Long generatedKey = (Long) sqlMapClient.insert("insertContact", contact)

Hope this will guide you to a working solution.

Greetings

Christian

Mime
View raw message