[ 
http://issues.apache.org/jira/browse/IBATIS-207?page=comments#action_12355862 ] 

Clinton Begin commented on IBATIS-207:
--------------------------------------

>From page 15 of the developer guide:

Auto-Generated Keys
Many relational database systems support auto-generation of primary key fields. 
This feature of the
RDBMS is often (if not always) proprietary. Data Mapper supports auto-generated 
keys via the
<selectKey> stanza of the <insert> element. Both pre-generated keys (e.g. 
Oracle) and post-generated
(MS-SQL Server) keys are supported. Here are a couple of examples:

<!—Oracle SEQUENCE Example -->
<insert id="insertProduct-ORACLE" parameterClass="com.domain.Product">
<selectKey resultClass="int" >
SELECT STOCKIDSEQUENCE.NEXTVAL AS ID FROM DUAL
</selectKey>
insert into PRODUCT (PRD_ID,PRD_DESCRIPTION)
values (#id#,#description#)
</insert>

<!— Microsoft SQL Server IDENTITY Column Example -->
<insert id="insertProduct-MS-SQL" parameterClass="com.domain.Product">
insert into PRODUCT (PRD_DESCRIPTION)
values (#description#)
<selectKey resultClass="int" >
SELECT @@IDENTITY AS ID
</selectKey>
</insert>

> Missing selectKey DTD parameter
> -------------------------------
>
>          Key: IBATIS-207
>          URL: http://issues.apache.org/jira/browse/IBATIS-207
>      Project: iBatis for Java
>         Type: Bug
>     Versions: 2.1.5
>  Environment: Windows XP, MySQL
>     Reporter: Paul Benedict
>     Priority: Critical

>
> According to this URL, the selectKey parameter is supposed to contain a type 
> attribute so that users can run the statement post insert: 
> http://opensource2.atlassian.com/confluence/oss/display/IBATIS/How+do+I+use+an+insert+statement%3F+cs
> However, no such attribute exists and the following error occurs:
> Caused by: org.xml.sax.SAXParseException: Attribute "type" must be declared 
> for element type "selectKey".
> Recommended solution:
> Correct DTD to contain attribute. The SelectKeyStatement class contains an 
> "after" property, but there is no way to set this through the current DTD.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to