• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
pankaj semwal
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi list[],
I am getting following exception :



And i am calling like this



Pl tell me where i am wrong.
 
Waswani Naresh
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
joy b chakravarty
Ranch Hand
Posts: 62
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..


 
pankaj semwal
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for reply,
I solve the problem as i use alias name like this.




 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic