数据查询

hibernate 的 save(Entity some)会返回一个对象带id

public T save(T object) {
return dao.save(object);



如果是mysql写的 在插入完毕之后 :
String sql = " select max(sche_id) from studio_sche_class ";
BigInteger maxId = (BigInteger) getSession().createSQLQuery(sql).uniqueResult();
return maxId.longValue();



返回的maxid就是之前插入的 不用+1
posted @ 2016-03-30 10:30  FEI_>.<_JI  阅读(136)  评论(0编辑  收藏  举报