You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Thanh PHAM <de...@pham.me> on 2009/10/07 11:17:50 UTC

useGeneratedKeys, data not inserted, ibatis 3.0 trunk and sql 2005

Hi,

I tried to use useGeneratedKeys for mssql 2005, latest driver version.
The identity is incremented and everything seem OK but the data is not
present in the table.

Here is my xml and log.

<insert id="insertXtp" parameterType="map" keyProperty="id"
useGeneratedKeys="true">
    insert into xtp_selectkey (label) values (#{label})
</insert>

setting : <setting name="useGeneratedKeys" value="true"/>

Driver version 2.0.1803.100 sqljdbc.jar
ibatis version : 3.0-beta4 7 Oct 2009

log :
Connection (26) - ooo Connection Opened
PreparedStatement (26) - ==>  Executing: insert into xtp_selectkey (label)
values (?)
PreparedStatement (26) - ==> Parameters: title(String)
Connection (26) - xxx Connection Closed

Re: useGeneratedKeys, data not inserted, ibatis 3.0 trunk and sql 2005

Posted by Thanh PHAM <de...@pham.me>.
You're right, I thought the auto-commit is by default.

Thanks for the response and sorry for my spam.


2009/10/7 Poitras Christian <Ch...@ircm.qc.ca>

>  Did you call SqlSession.commit() and SqlSession.close()?
>
> The usual pattern is
> SqlSession sqlSession = sqlSessionFactory.openSession();
> try {
>   // Do come inserts / updates / deletes
>   sqlSession.commit();
> } finally {
>   sqlSession.close();
> }
>
> Christian
>
>  ------------------------------
> *From:* Thanh PHAM [mailto:dev@pham.me]
> *Sent:* Wednesday, October 07, 2009 5:18 AM
> *To:* user-java@ibatis.apache.org
> *Subject:* useGeneratedKeys, data not inserted, ibatis 3.0 trunk and sql
> 2005
>
> Hi,
>
> I tried to use useGeneratedKeys for mssql 2005, latest driver version.
> The identity is incremented and everything seem OK but the data is not
> present in the table.
>
> Here is my xml and log.
>
> <insert id="insertXtp" parameterType="map" keyProperty="id"
> useGeneratedKeys="true">
>     insert into xtp_selectkey (label) values (#{label})
> </insert>
>
> setting : <setting name="useGeneratedKeys" value="true"/>
>
> Driver version 2.0.1803.100 sqljdbc.jar
> ibatis version : 3.0-beta4 7 Oct 2009
>
> log :
> Connection (26) - ooo Connection Opened
> PreparedStatement (26) - ==>  Executing: insert into xtp_selectkey (label)
> values (?)
> PreparedStatement (26) - ==> Parameters: title(String)
> Connection (26) - xxx Connection Closed
>

RE: useGeneratedKeys, data not inserted, ibatis 3.0 trunk and sql 2005

Posted by Poitras Christian <Ch...@ircm.qc.ca>.
Did you call SqlSession.commit() and SqlSession.close()?

The usual pattern is
SqlSession sqlSession = sqlSessionFactory.openSession();
try {
  // Do come inserts / updates / deletes
  sqlSession.commit();
} finally {
  sqlSession.close();
}

Christian

________________________________
From: Thanh PHAM [mailto:dev@pham.me]
Sent: Wednesday, October 07, 2009 5:18 AM
To: user-java@ibatis.apache.org
Subject: useGeneratedKeys, data not inserted, ibatis 3.0 trunk and sql 2005

Hi,

I tried to use useGeneratedKeys for mssql 2005, latest driver version.
The identity is incremented and everything seem OK but the data is not present in the table.

Here is my xml and log.

<insert id="insertXtp" parameterType="map" keyProperty="id" useGeneratedKeys="true">
    insert into xtp_selectkey (label) values (#{label})
</insert>

setting : <setting name="useGeneratedKeys" value="true"/>

Driver version 2.0.1803.100 sqljdbc.jar
ibatis version : 3.0-beta4 7 Oct 2009

log :
Connection (26) - ooo Connection Opened
PreparedStatement (26) - ==>  Executing: insert into xtp_selectkey (label) values (?)
PreparedStatement (26) - ==> Parameters: title(String)
Connection (26) - xxx Connection Closed