取序列时 dual is not mapped

项目中,用到一个序列作单号,框架用的是ssh,在dao层去拿的时候,运行时报错为dual is not mapped,[select out_libr_seq.nextval nextvalue from dual]

           后来检查发现,获取方式不对,于是改成下面这样,就可以正常获取了

String sql="select out_libr_seq.nextval nextvalue from dual";
		Integer maxId = (Integer)(this.getSession().createSQLQuery(sql).addScalar("nextvalue", Hibernate.INTEGER) ).uniqueResult();  
		return maxId.toString(); 

猜你喜欢

转载自blog.csdn.net/qq_36744695/article/details/80500690