1. 程式人生 > >今天解決的兩個BUG--暫且這麼命名

今天解決的兩個BUG--暫且這麼命名

1. Mysql + MyBatis 插入一條資料返回自增型主鍵值。在XML 中 <insert id="insertEx"> *** </insert>中加一句:

<selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="deptId">
	SELECT LAST_INSERT_ID()
</selectKey>

keyProperty 是Bean中的欄位而非 資料表的列名。!!!

在使用上,

User user = new User;
---
insertEx(user);//返回為0,1
int getId = user.getUserId;


2.自動生成的Bean(Domain)中,int 一般為Integer,當需要兩個比較的時候需要注意。。使用equals