dual is not mapped,select ordercode_seq_id.nextval nextvalue from dual

来源:互联网 发布:曾经的网络流行语 编辑:程序博客网 时间:2024/05/12 00:32

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

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

Java代码 
  1. public String getOrderCode() {  
  2.     try {  
  3.         String sql = "select ordercode_seq_id.nextval nextvalue from dual";  
  4.         Integer maxId = (Integer)(this.getSession().createSQLQuery(sql).addScalar("nextvalue", Hibernate.INTEGER) ).uniqueResult();  
  5.         return maxId.toString();  
  6.     } catch (Exception e) {  
  7.         e.printStackTrace();  
  8.     }  
  9.     return null;  
  10. }  
原创粉丝点击