日期:2014-05-16  浏览次数:20869 次

ibatis中mysql、oracle的区别

ibatis中mysql、oracle的区别:

mysql中主键自动增长为后生成主键
例如:
<insert id="insert" parameterClass="student">
insert into student(name,profession) values(#name#,#profession#)
<selectKey resultClass="java.lang.Integer" keyProperty="id">
<![CDATA[SELECT LAST_INSERT_ID() AS ID]]>
</selectKey>
</insert>

oracle中主键自动增长为预生成主键
例如:
<insert id="insert" parameterClass="student">
<selectKey resultClass="java.lang.Integer" keyProperty="id">
SELECT STUDENT_SEQUENCE.NEXTVAL AS ID FROM DUAL
</selectKey>
insert into student(id,name,profession) values(#id#,#name#,#profession#)
</insert>

?