MYSQL定义的id字段为bigint
<insert id="addUser" parameterType="User" useGeneratedKeys="true" keyProperty="id" keyColumn="id">
<selectKey resultType="long" keyProperty="id" order="AFTER">
SELECT LAST_INSERT_ID();
</selectKey>
<![CDATA[
INSERT INTO users(loginName,password,email,lastLoginIp)
VALUES(#{loginName},#{password},#{email},#{lastLoginIp})
]]>
</insert>
错误信息
java.lang.Integer cannot be cast to java.lang.Long
改成 SELECT @@IDENTITY AS id
错误信息也是一样
求高手指导。。。把<selectKey resultType="long" keyProperty="id" order="AFTER">
改成<selectKey resultType="int" keyProperty="id" order="AFTER">试试呢
很长时间没写代码了,这样试试;