#1 -- I'm trying to use selectKey to create keys for me. DB is Sybase.

My insert is as follows:

    <insert id="createDeployment" parameterClass="deployment">
        INSERT INTO Deployment (environmentId, deploymentTypeId, userName,
deploymentStatusId, deploymentTime, threadCountOverride)
        VALUES (#environmentId#, #deploymentTypeId#, #userName#,          
     #deploymentStatusId#, #deploymentTime#,
#threadCountOverride#)       <selectKey resultClass="int"
keyProperty="deploymentId">
            SELECT @@IDENTITY AS deploymentId
        </selectKey>
    </insert>

(BTW the dev guide does not mention keyProperty -- I found that in this
thread:
http://www.mail-archive.com/user-java@ibatis.apache.org/msg00044.html)


I get the following error:

Caused by: com.sybase.jdbc3.jdbc.SybSQLException: The column deploymentId
in table Deployment does not allow null values.

        at
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:91)
        at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.insert(SqlMapExecutorDelegate.java:442)
        at
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.insert(SqlMapSessionImpl.java:81)
        at
org.springframework.orm.ibatis.SqlMapClientTemplate$9.doInSqlMapClient(SqlMapClientTemplate.java:319)
        at
org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:181)
        at
org.springframework.orm.ibatis.SqlMapClientTemplate.insert(SqlMapClientTemplate.java:317)


#2 -- Given that the insert/update statements are very much alike, is
there a clean way to share the SQL between the two?

Thanks
Reuben

Reply via email to