MyBatis插入操作後利用Bean返回id

例子:

AuditProcessBean processBean = new AuditProcessBean();
                processBean.setOpen_id(auditSubmitDto.getOpen_id());
                processBean.setCreate_time(new Date());
                processBean.setCur_task(ProcessCode.M00012);
                auditProcessDao.insert(processBean);
                LOGGER.info("審覈通過,插入複覈記錄成功,id:{}", processBean.getId());

該用例之所以可以直接獲得    processBean.getId()   由於

<insert id="insert" parameterType="AuditProcessBean" useGeneratedKeys="true" keyProperty="id">

增加    useGeneratedKeys="true" keyProperty="id"  兩個屬性

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章