ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Zhongmin Chen <zhongmin.c...@gmail.com>
Subject Re: Insert returned object is NULL
Date Wed, 01 Feb 2006 22:25:43 GMT
Thanks! This fixed the NULL object problem.

I still have one doubt. I am using MySQL 5.0, and have the field - id
defined as below:

  id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,

and the statement as below:

  <insert>
        insert into client(client_name)
        values(#clientName#)

        <selectKey resultClass="long">
            select max(id) from client
        </selectKey>
    </insert>

But it is possible that multiple insert operation is doing at the same time,
so I am not sure whether the max(id) is the id of the newly inserted client.

Thanks!
Zhongmin


On 2/1/06, Niels Beekman <n.beekman@wis.nl> wrote:
>
> Just in case: did you use the <selectKey>-element within your insert
> statement?
>
> Niels
> ________________________________________
> From: Zhongmin Chen [mailto:zhongmin.chen@gmail.com]
> Sent: woensdag 1 februari 2006 22:03
> To: user-java@ibatis.apache.org
> Subject: Insert returned object is NULL
>
> Hi,
>
> I am using Spring with iBATIS, and calling the following method:
>
>
>
> org.springframework.orm.ibatis.support.SqlMapClientDaoSupport.getSqlMapClientTemplate().insert("statement",
> parameterObj);
>
>
> which is calling the insert method of iBATIS SQL Map:
> public java.lang.Object insert(java.lang.Stringid,
>                                 java.lang.ObjectparameterObject)
>                         throws
> java.sql.SQLException
>
>
> It is supposed to return "The primary key of the newly inserted row", but
> I got a NULL object.
>
> Anybody know why?
>
> Thanks in advance!
>
> Zhongmin
>

Mime
View raw message