hibernate查询错误

05-07-20 Objecter
兄弟刚用Hibernate,现在遇到问题,请大家帮忙分析一下原因:

类:

public String getSysTime(String strFormat) throws HibernateException {

net.sf.hibernate.Session sessionT4 = null;

String strSysTime = new String("");

FMJF01TDAO.initialize();

FMJF01TDAO dao01 = new FMJF01TDAO();

sessionT4 = dao01.createNewSession();

StringBuffer strBufSql = new StringBuffer(); strBufSql.append("select distinct to_char(sysdate,'yy') as systime from fmjf01t ");

net.sf.hibernate.Query query = sessionT4.createQuery(strBufSql.toString());

ScrollableResults sc = query.scroll();

if (sc.next()) {

System.out.println("data exist");

}

return "yes";

}

Exception:

net.sf.hibernate.QueryException: , expected in SELECT [select distinct to_char(sysdate,'yy') as systime from fmjf01t ]

at net.sf.hibernate.hql.SelectParser.token(SelectParser.java:169)

at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87)

at net.sf.hibernate.hql.ClauseParser.end(ClauseParser.java:114)

at net.sf.hibernate.hql.PreprocessingParser.end(PreprocessingParser.java:143)

at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:30)

at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:149)

at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:138)

at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:295)

at net.sf.hibernate.impl.SessionImpl.scroll(SessionImpl.java:1646)

at net.sf.hibernate.impl.QueryImpl.scroll(QueryImpl.java:33)

at jp.co.melco.monoris.FDC.util.FMJF11C.getSysTime(FMJF11C.java:91)

at jp.co.melco.monoris.FDC.util.FMJF11C.chkYear(FMJF11C.java:668)

at jp.co.melco.monoris.FDC.util.FMJF11C.main(FMJF11C.java:914)

Objecter
2005-07-20 23:06
net.sf.hibernate.exception.GenericJDBCException: Could not execute query

at net.sf.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java:90)

at net.sf.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:79)

at net.sf.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:30)

at net.sf.hibernate.impl.SessionImpl.convert(SessionImpl.java:4110)

at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1556)

at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)

at jp.co.melco.monoris.FDC.util.FMJF11C.getSysTime(FMJF11C.java:111)

at jp.co.melco.monoris.FDC.util.FMJF11C.main(FMJF11C.java:1070)

Caused by: java.sql.SQLException:数值的溢出

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:124)

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:161)

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:226)

at oracle.jdbc.driver.NumberCommonAccessor.throwOverflow(NumberCommonAccessor.java:6796)

at oracle.jdbc.driver.NumberCommonAccessor.getInt(NumberCommonAccessor.java:105)

at oracle.jdbc.driver.OracleResultSetImpl.getInt(OracleResultSetImpl.java:489)

at oracle.jdbc.driver.OracleResultSet.getInt(OracleResultSet.java:1604)

at net.sf.hibernate.type.IntegerType.get(IntegerType.java:21)

at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:62)

at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:53)

at net.sf.hibernate.type.AbstractType.hydrate(AbstractType.java:66)

at net.sf.hibernate.loader.Loader.hydrate(Loader.java:686)

at net.sf.hibernate.loader.Loader.loadFromResultSet(Loader.java:627)

at net.sf.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:586)

at net.sf.hibernate.loader.Loader.getRow(Loader.java:501)

at net.sf.hibernate.loader.Loader.getRowFromResultSet(Loader.java:213)

at net.sf.hibernate.loader.Loader.doQuery(Loader.java:281)

at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)

at net.sf.hibernate.loader.Loader.doList(Loader.java:1033)

at net.sf.hibernate.loader.Loader.list(Loader.java:1024)

at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:854)

at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1553)

... 3 more

Objecter
2005-07-20 23:08
什么原因造成数值溢出的

是否表中数据查询字段过多引起的

我用几个字段的表进行查询就没有问题

请斑竹帮忙回答,谢谢!

猜你喜欢