自增表新插一条数据后,获取插入数据的id:
mapper.xml
<select id="selectIdentity" resultType="java.lang.Long">
SELECT @@identity
</select>
mapper.java
Long selectIdentity();
代码中insert后直接调用即可获取刚才插入数据的id
Long id = jobMapper.selectIdentity();
自增表新插一条数据后,获取插入数据的id:
mapper.xml
<select id="selectIdentity" resultType="java.lang.Long">
SELECT @@identity
</select>
mapper.java
Long selectIdentity();
代码中insert后直接调用即可获取刚才插入数据的id
Long id = jobMapper.selectIdentity();