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