当前位置: 代码迷 >> Java Web开发 >> 们,快点过来瞅瞅,搞的头都大了.关于ORA-01858的有关问题
  详细解决方案

们,快点过来瞅瞅,搞的头都大了.关于ORA-01858的有关问题

热度:262   发布时间:2016-04-17 10:19:12.0
大虾们,快点过来瞅瞅,搞的头都大了.关于ORA-01858的问题.在线等
这是代码:
public Page pageCount(Page page,String userName,String startDate,String endDate,String deptid){
String sql="select sum(cnt) from (select count(*) as cnt from t_humn_leave where DELFLAG=0 and USERID in (select ID from T_APP_USER where NAME like ? ) and startDate between ? and ? " +
" union select count(*) from t_humn_overtime where DELFLAG=0 and USERID in (select ID from T_APP_USER where NAME like ? ) and startDate between ? and ? " +
" union select count(*) from t_humn_training where DELFLAG=0 and USERID in (select ID from T_APP_USER where NAME like ? ) and startDate between ? and ? )";
Query queryCount= getSession().createSQLQuery(sql);
queryCount.setParameter(0, "'%"+userName+"%'");
queryCount.setParameter(1, "to_date("+startDate+", 'yyyy-mm-dd hh24:mi:ss')");
queryCount.setParameter(2, "to_date("+endDate+", 'yyyy-mm-dd hh24:mi:ss')");
queryCount.setParameter(3, "'%"+userName+"%'");
queryCount.setParameter(4, "to_date("+startDate+", 'yyyy-mm-dd hh24:mi:ss')");
queryCount.setParameter(5, "to_date("+endDate+", 'yyyy-mm-dd hh24:mi:ss')");
queryCount.setParameter(6, "'%"+userName+"%'");
queryCount.setParameter(7, "to_date("+startDate+", 'yyyy-mm-dd hh24:mi:ss')");
queryCount.setParameter(8, "to_date("+endDate+", 'yyyy-mm-dd hh24:mi:ss')");
Object count =queryCount.uniqueResult();
//Query query = getSession().createSQLQuery(sql).addEntity(entityClass);
//query.list();
String sql1="select '请假',DEPTID,USERID,STARTDATE,ENDDATE,RECORDER,REMARK,ID from t_humn_leave where DELFLAG=0 and USERID in (select ID from T_APP_USER where NAME like ? ) and startDate between ? and ? " +
"union select '加班',DEPTID,USERID,startDate,endDate,RECORDER,REMARK,ID from t_humn_overtime where DELFLAG=0 and USERID in (select ID from T_APP_USER where NAME like ? ) and startDate between ? and ? " +
" union select '外出培训',DEPTID,USERID,startDate,endDate,RECORDER,REMARK,ID from t_humn_training where DELFLAG=0 and USERID in (select ID from T_APP_USER where NAME like ? ) and startDate between ? and ? ";
Query query=getSession().createSQLQuery(sql1);
query.setParameter(0, "%"+userName+"%");
query.setParameter(1, "to_date('"+startDate+"', 'yyyy-mm-dd')");
query.setParameter(2, "to_date('"+endDate+"', 'yyyy-mm-dd')");
query.setParameter(3, "%"+userName+"%");
query.setParameter(4, "to_date('"+startDate+"', 'yyyy-mm-dd')");
query.setParameter(5, "to_date('"+endDate+"', 'yyyy-mm-dd')");
query.setParameter(6, "%"+userName+"%");
query.setParameter(7, "to_date('"+startDate+"', 'yyyy-mm-dd')");
query.setParameter(8, "to_date('"+endDate+"', 'yyyy-mm-dd')");
System.out.println("三表总记录条数"+count);
List list = query.list();
page.setResult(list);
page.setTotalCount(((Number)count).longValue());
return page;
}
这是错误:
2012-04-06 15:04:13,953 [http-8686-6] WARN [org.hibernate.util.JDBCExceptionReporter] - SQL Error: 1858, SQLState: 22008
2012-04-06 15:04:13,953 [http-8686-6] ERROR [org.hibernate.util.JDBCExceptionReporter] - ORA-01858: 在要求输入数字处找到非数字字符
2012-04-06 15:05:02,109 [http-8686-6] ERROR [500.jsp] - could not execute query
org.hibernate.exception.DataException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:102)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.doList(Loader.java:2452)
  相关解决方案
本站暂不开放注册!
内测阶段只得通过邀请码进行注册!
 
  • 最近登录:Sat Nov 25 08:04:08 CST 2017
  • 最近登录:Sat Nov 25 08:04:08 CST 2017
  • 最近登录:Sat Nov 25 08:04:08 CST 2017
  • 最近登录:Sat Nov 25 08:04:08 CST 2017
  • 最近登录:Sat Nov 25 08:04:08 CST 2017