ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ron H <be.spec...@gmail.com>
Subject Re: what contain int return value for insert?
Date Sun, 15 Nov 2009 11:20:20 GMT

well, the question is how to retrieve this Group.id?

Edvin Syse wrote:
> 
> You also know that Group.id will contain the result from the selectKey 
> statement :)
> 
> Jeff Butler skrev:
>> The return value from the insert method is the number of rows inserted
>> (in iBATIS3).
>>
>> Ibator will generated the proper code for generated keys - see the
>> <generatedKey> configuration element in the documentation.
>>
>> Jeff Butler
>>
>>
>> 2009/11/14 Tomáš Procházka <t.prochazka@centrum.cz>:
>>   
>>> What contain return int value for this mapper method:
>>>
>>> int insert(Group record);
>>>
>>> with this mapping delcaration:
>>>
>>>  <insert id="insert" parameterType="test.model.Group" >
>>>    insert into `group` (id, name, type,
>>>      locked, lockedby_user)
>>>    values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR},
>>> #{type,jdbcType=CHAR},
>>>      #{locked,jdbcType=BIT}, #{lockedbyUser,jdbcType=INTEGER})
>>>  </insert>
>>>
>>> ?
>>>
>>> A prefer automatically return last insert id, it's possible?
>>>
>>> I tried this:
>>>
>>>                <selectKey keyProperty="id" resultType="integer">
>>>                         SELECT LAST_INSERT_ID();
>>>                </selectKey>
>>>
>>> It update field in Group instance which was used to call insert method,
>>> But has no result to insert method return value.
>>>
>>>
>>>                <selectKey keyProperty="id" resultType="integer"> SELECT
>>> LAST_INSERT_ID();</selectKey>
>>>
>>> This should be automatically generated by Ibator. It's very important
>>> for easy way to build related DB data.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>>> For additional commands, e-mail: user-java-help@ibatis.apache.org
>>>
>>>
>>>     
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>> For additional commands, e-mail: user-java-help@ibatis.apache.org
>>
>>   
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/what-contain-int-return-value-for-insert--tp26352739p26358246.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Mime
View raw message