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: get id with iBatis (Statement.RETURN_GENERATED_KEYS)
Date Tue, 16 May 2006 19:37:25 GMT
This is probably a result of using some iBATIS 2.0 elements inside an iBATIS
1.0 sql map.  You need to consistently use the version 2.0 DTD like this:

<!DOCTYPE sqlMap
  PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
  "http://ibatis.apache.org/dtd/sql-map-2.dtd">

<sqlMap namespace="Organizations">

<insert id="InsertOrganization" parameterClass="Organization"
resultClass="int">
       <selectKey property="Id" type="post" resultClass="int">
               SELECT LAST_INSERT_ID() AS value
       </selectKey>
       INSERT INTO Organizations
               (Org_Code, Org_Name)
       VALUES
               (#Code#, #Name#)
</insert>

</sqlMap>


Jeff Butler


On 5/16/06, xianwinwin <xianwinwin@gmail.com> wrote:
>
>
> thank you for your reply Jeff.
>
> I looked at the documentation and tried (unsuccessfully) some of the
> examples.
>
> I tried somthing that looks like this:
> <?xml version="1.0" encoding="UTF-8"?>
>
> <!DOCTYPE sql-map
>   PUBLIC "-//iBATIS.com//DTD SQL Map 1.0//EN"
>   "http://www.ibatis.com/dtd/sql-map.dtd">
>
> <sql-map name="Organizations">
>
> <insert id="InsertOrganization" parameterClass="Organization"
> resultClass="int">
>        <selectKey property="Id" type="post" resultClass="int">
>                SELECT LAST_INSERT_ID() AS value
>        </selectKey>
>        INSERT INTO Organizations
>                (Org_Code, Org_Name)
>        VALUES
>                (#Code#, #Name#)
> </insert>
>
> </sql-map>
>
>
> I keep getting the following error cause: Element "sqlMap" requires
> additional elements.
> any idea?
>
> --
> View this message in context:
> http://www.nabble.com/get-id-with-iBatis-%28Statement.RETURN_GENERATED_KEYS%29-t1629789.html#a4415947
> Sent from the iBATIS - User - Java forum at Nabble.com.
>
>

Mime
View raw message