sess.createSQLQuery("INSERT INTO ARCHIVE (folder) VALUES(:folder)")
.setParameter("folder",path)
.executeUpdate();
我想拥有新创建的对象的id。我怎么能这样做?
答案 0 :(得分:3)
试试吧
Integer lastId =(Integer)session.createSQLQuery(" SELECT LAST_INSERT_ID()") .uniqueResult();