Hi,
I'm performing a subquery and I have a requirement saying that I'm only interested in data from a specific date. But Hibernate throws an exception. In the database the date format is datatype "date" (23-OCT-03) and in the Java classes the date has the datatype "Date".
This is my query:
Query q = session.createQuery("SELECT co.customerT.customerTPK.customerno, "
+ "co.customerorderTPK.customerorderno "
+ "FROM net.sf.hibernate.CustomerorderT co "
+ "WHERE
co.deliverydate='23-OCT-03' "
+ "AND co.customerorderTPK.customerorderno IN "
+ "(SELECT col.customerorderlineTPK.customerorderT.customerorderTPK.customerorderno "
+ "FROM net.sf.hibernate.CustomerorderlineT col "
+ "WHERE col.articlename='MIL GOLVLAMPA SV')");
Hibernate says that "a non-numeric character was found where a numeric was expected". This is the full output:
Code:
10:14:01,152 DEBUG SQL:237 - select customeror0_.CUSTOMERNO as x0_0_, customeror0_.CUSTOMERORDERNO as x1_0_ from CUSTOMERORDER_T customeror0_ where (customeror0_.DELIVERYDATE='23-OCT-03' )AND(customeror0_.CUSTOMERORDERNO IN(select customeror1_.CUSTOMERORDERNO from CUSTOMERORDERLINE_T customeror1_ where (customeror1_.ARTICLENAME='MIL GOLVLAMPA SV' )))
10:14:01,199 WARN JDBCExceptionReporter:38 - SQL Error: 1858, SQLState: 22008
10:14:01,214 ERROR JDBCExceptionReporter:46 - ORA-01858: a non-numeric character was found where a numeric was expected
10:14:01,246 WARN JDBCExceptionReporter:38 - SQL Error: 1858, SQLState: 22008
10:14:01,277 ERROR JDBCExceptionReporter:46 - ORA-01858: a non-numeric character was found where a numeric was expected
10:14:01,292 ERROR JDBCExceptionReporter:38 - Could not execute query
java.sql.SQLException: ORA-01858: a non-numeric character was found where a numeric was expected
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405)
at oracle.jdbc.ttc7.TTC7Protocol.fetch(TTC7Protocol.java:889)
at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:1681)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1870)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:363)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:314)
at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:87)
at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:795)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:189)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:950)
at net.sf.hibernate.loader.Loader.list(Loader.java:941)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:834)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1512)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
at net.sf.hibernate.TestCountryStore.subqueryOfCusorderCusorderline(TestCountryStore.java:239)
at net.sf.hibernate.TestCountryStore.menu(TestCountryStore.java:71)
at net.sf.hibernate.TestCountryStore.main(TestCountryStore.java:307)
When I run the query as a pure SQL I use "deliverydate='23-OCT-03'. But this doesn't work in Hibernate.
Has anyone got suggestions what to do?
Best regards
Newman