ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rolando Duma <rolando.d...@urmet.it>
Subject Problem with SYBASE @@identity
Date Fri, 06 Apr 2007 08:50:52 GMT
Hi all,
I'm having problems to retrieve identity column values on Sybase, this is my env:

Sybase 12.5.1 on Linux
jtds-1.2
iBatis 2.3.0
Spring 2.0.3

I'm using Abator (Java5 generator set) SPRING DAO's with Spring declarative transactions,
this is my
abator config

    <table tableName="numeri">
      <generatedKey column="ID" identity="true" sqlStatement="select @@identity"/>
    </table>

the generated sqlmap

  <insert id="abatorgenerated_insert" parameterClass="it.urmet.scgd.model.Numeri">
    insert into numeri (nome, numero)
    values (#nome:VARCHAR#, #numero:VARCHAR#)
    <selectKey keyProperty="id" resultClass="java.lang.Long">
      select @@identity
    </selectKey>
  </insert>

and this  is what happens:

...
[btpool0-6] TransactionInterceptor.prepareTransactionInfo(279) | Getting transaction for
[it.urmet.scgd.dao.NumeriDAO.insert]
[btpool0-6] TransactionSynchronizationManager.getResource(136) | Retrieved value
[org.springframework.jdbc.datasource.ConnectionHolder@1d1a35e] for key [org.apache.commons.dbcp.Bas
icDataSource@ed3007] bound to thread [btpool0-6]
[btpool0-6] TransactionSynchronizationManager.bindResource(163) | Bound value
[org.springframework.jdbc.datasource.ConnectionHolder@3cb1e1] for key
[org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy@c678c7] to thread [btpool0-6]
[btpool0-6] Connection.debug(27) | {conn-100010} Connection
[btpool0-6] Connection.debug(27) | {conn-100010} Preparing Statement: insert into numeri (nome,
numero)     values (?, ?)
[btpool0-6] TransactionSynchronizationManager.getResource(136) | Retrieved value
[org.springframework.jdbc.datasource.ConnectionHolder@1d1a35e] for key [org.apache.commons.dbcp.Bas
icDataSource@ed3007] bound to thread [btpool0-6]
[btpool0-6] PreparedStatement.debug(27) | {pstm-100011} Executing Statement: insert into numeri
(nome, numero)     values (?, ?)
[btpool0-6] PreparedStatement.debug(27) | {pstm-100011} Parameters: [fewrfw, 5476984768]
[btpool0-6] PreparedStatement.debug(27) | {pstm-100011} Types: [java.lang.String, java.lang.String]
[btpool0-6] Connection.debug(27) | {conn-100010} Preparing Statement:        select @@identity
[btpool0-6] TransactionSynchronizationManager.getResource(136) | Retrieved value
[org.springframework.jdbc.datasource.ConnectionHolder@1d1a35e] for key [org.apache.commons.dbcp.Bas
icDataSource@ed3007] bound to thread [btpool0-6]
[btpool0-6] PreparedStatement.debug(27) | {pstm-100012} Executing Statement:   select @@identity
[btpool0-6] PreparedStatement.debug(27) | {pstm-100012} Parameters: []
[btpool0-6] PreparedStatement.debug(27) | {pstm-100012} Types: []
[btpool0-6] ResultSet.debug(27) | {rset-100013} ResultSet
[btpool0-6] ResultSet.debug(27) | {rset-100013} Header: []
[btpool0-6] ResultSet.debug(27) | {rset-100013} Result: [0]
...

The problem is that "select @@identity always returns 0.Can someone help me, please.
TIA


--------------------------------------------
INFORMATIVA SULLA PRIVACY
Ai sensi del D.Lgs. 196/2003 si precisa che le informazioni contenute
in questo messaggio e nei suoi eventuali allegati sono riservate e per
uso esclusivo del destinatario. Nessuno, all'infuori dello stesso,
può copiare o distribuire il messaggio, o parte di esso, a terzi.
Chiunque riceva questo messaggio per errore è pregato di distruggerlo
e di informare il mittente.

PRIVACY NOTICE
According to the D.Lgs. 196/2003 this document and its attachments are
confidential and intended for the named addressee(s) only. If you are
not the intended recipient of this message, any use or dissemination
of this message is prohibited. If you have received this document by
mistake, please notify the sender and destroy all physical and/or
electronic copies.

Mime
View raw message