-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Date problem in subqueries
PostPosted: Wed Jun 02, 2004 4:30 am 
Regular
Regular

Joined: Tue May 11, 2004 9:23 am
Posts: 69
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


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 02, 2004 5:05 am 
Regular
Regular

Joined: Tue May 11, 2004 9:23 am
Posts: 69
Has noone got ideas how to manage dates with hibernate?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 02, 2004 5:06 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Please do use parameters - don't use arguments that are pasted like this - its evil. You pass in an appropriate Date object initiased to the date your after.
Otherwise you may need to do a string conversion on the date type (since you are comparing strings).


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 02, 2004 5:07 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
It is not neccessary to ask every hour.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 02, 2004 5:37 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Ah, I can see the pattern. In almost all of your 40 threads/questions you immediately ask again one hour after posting the initial question. You apparently found out that people get really annoyed if someone whines "please please help me" and help you immediately.

This has to stop. Don't do that.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.