• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HQL retrieve based on a date column

 
peter tong
Ranch Hand
Posts: 250
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to write a HQL statement which retrieve record based on date part of a column only, not include time portion?
I see some forums say using trunc() function, but I got sql grammar exception.

15:17:43,102 [Timer-1] ERROR JDBCExceptionReporter - 'trunc' is not a recognized
function name.
15:17:43,542 [Timer-1] ERROR InitServlet - Exception in BackendTimerTask
org.springframework.dao.InvalidDataAccessResourceUsageException: could not execu
te query; nested exception is org.hibernate.exception.SQLGrammarException: could
not execute query
Caused by:
org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.j
ava:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelp
er.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:2223)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java:2099)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.ja
va:338)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java
:172)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at com.armitage.royalGarden.store.InventoryBeanDaoImpl$1.doInHibernate(I
nventoryBeanDaoImpl.java:65)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(Hibernat
eTemplate.java:372)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(Hibernat
eTemplate.java:338)
at com.armitage.royalGarden.store.InventoryBeanDaoImpl.getRoomInventoryM
apByDate(InventoryBeanDaoImpl.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflecti
on(AopUtils.java:304)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJo
inpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.in
voke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynami
cAopProxy.java:204)
at $Proxy15.getRoomInventoryMapByDate(Unknown Source)
at com.armitage.royalGarden.extension.InitServlet$BackendTimerTask.run(I
nitServlet.java:86)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic