Mybatis插入後返回主鍵id

   //返回插入id
    @Insert("insert into notice(title,content,username,createTime) values(#{title},#{content},#{username},NOW())")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int save(Notice notice) throws Exception;

主鍵id自動封裝進傳入對象中

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