wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes org.hibernate.exception.SQLGrammarException: could not execute query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "org.hibernate.exception.SQLGrammarException: could not execute query" Watch "org.hibernate.exception.SQLGrammarException: could not execute query" New topic
Author

org.hibernate.exception.SQLGrammarException: could not execute query

pankaj semwal
Ranch Hand

Joined: Oct 07, 2008
Posts: 300
Hi list[],
I am getting following exception :



And i am calling like this



Pl tell me where i am wrong.
Waswani Naresh
Ranch Hand

Joined: May 01, 2008
Posts: 66
criteria.add(Restrictions.sqlRestriction(" TO_CHAR(BRCD_CRTE_TIME,'YYYYMMDD')BETWEEN '" +fromDate+ "' AND '"+ toDate+"'" ));


There is no space before 'BETWEEN'. Try giving a space before it.

Regards,
Naresh Waswani


Naresh Waswani
joy b chakravarty
Ranch Hand

Joined: May 16, 2011
Posts: 62

From what I understand the problem doesn't lie in the Between cluase

If you look at the generated query you have something like this
select this_.BRCD_DLR_NO as y0_, this_.BRCD_PART_NO as y1_,
...
where TO_CHAR(BRCD_CRTE_TIME,'YYYYMMDD')BETWEEN '20110728' AND '20110729' and y1_=?
This should have been this_.BRCD_PART_NO = ?

i think use of Projections is causing this to happen..



Cheers, Joy [SCJP 1.4, SCBCD 5.0]
get high on alcohol, algorithm or both
pankaj semwal
Ranch Hand

Joined: Oct 07, 2008
Posts: 300
Thanks for reply,
I solve the problem as i use alias name like this.




 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: org.hibernate.exception.SQLGrammarException: could not execute query
 
Similar Threads
select with an "in" clause...
Hibernate Criterion query: org.hibernate.exception.SQLGrammarException: could not execute query
invalid host/bind variable name
Hibernate native sql problem
java.sql.SQLException: ORA-01733: virtual column not allowed here