日期:2014-05-17 浏览次数:20687 次
<insert id="insertAGenerated" parameterType="com.defonds.mybatis.test.bean.A" useGeneratedKeys="true" keyProperty="aId">
insert into a(aName)
values(#{aName})
</insert>
package com.defonds.mybatis.test.dao;
import com.defonds.mybatis.test.bean.A;
public interface AMapper {
void insertA(A a);
int insertAGenerated(A a);
}
package com.defonds.mybatis.test.bean;
public class A {
private int aId;
private String aName;
public int getaId() {
return aId;
}
public void setaId(int aId) {
this.aId = aId;
}
public String getaName() {
return aName;
}
public void setaName(String aName) {
this.aName = aName;
}
}
A a;
int aa = aMapper.insertAGenerated(a);