日期:2014-05-19  浏览次数:20719 次

mybatis中怎样让oracle自动生成主键
mybatis中怎样让oracle自动生成主键。在配置文件中该怎么写啊

------解决方案--------------------
<insert id="insert" parameterClass="com.macower.ibatis.demo.Contact" >
insert into contact(firstName,lastName,email)
values(#firstName#,#lastName#,#email#)
<selectKey resultClass="int" keyProperty="id">
select last_insert_id() as id 
</selectKey>
</insert>

package com.macower.ibatis.demo;
public class Contact {
private String firstName;
private String lastName;
private String email;
private int id;

ID
就是这样自动获取的!!
 <selectKey resultClass="int" keyProperty="id">
select last_insert_id() as id 
</selectKey>
------解决方案--------------------
学习了