ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Butler" <jeffgbut...@gmail.com>
Subject Re: Can Insert mapped statement be reuse?
Date Thu, 07 Aug 2008 19:56:15 GMT
If you setup your (a)ibator configurations using the <generatedKey> element,
then (a)ibator will generate the <selectKey> for you.  This is the best
solution, I think.

Jeff Butler

On Thu, Aug 7, 2008 at 2:45 PM, Doug Flex <doug_flex@yahoo.com> wrote:

>  Hi,
>
> I want to get the primary key (which is auto increment) return to my object
> after the insert statement.  I don't want to modify the generated insert
> statement from Sqlmap because I want to continue to take advantage of the
> generated code for future changes in the database.  Is there a way to reuse
> the insert statement similiar to the way you re-use SQL?
>
> 1) This is Abator generated code
>   <insert id="abatorgenerated_insert" parameterClass="MyClass">
>     insert sql statement here ....
>   </insert>
>
> 2) this is manual code is my attempt to reuse the generated insert
> statement in step 1.  But this doesn't work.  Is there a way to do this
> correctly?
>   <insert id="insert_withReturnId" parameterClass="MyClass">
>       <include refid="abatorgenerated_insert" />   <<-- THIS DOESN'T WORK
>         <selectKey resultClass="int" keyProperty="Id" type="post">
>             SELECT LAST_INSERT_ID()
>       </selectKey>
>   </insert>
>
>

Mime
View raw message