您的位置:首页 > 移动开发

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

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

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

Java代码 

public String getOrderCode() {  

    try {  

        String sql = "select ordercode_seq_id.nextval nextvalue from dual";  

        Integer maxId = (Integer)(this.getSession().createSQLQuery(sql).addScalar("nextvalue", Hibernate.INTEGER) ).uniqueResult();  

        return maxId.toString();  

    } catch (Exception e) {  

        e.printStackTrace();  

    }  

    return null;  

}  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Exception
相关文章推荐