-->
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.  [ 6 posts ] 
Author Message
 Post subject: Problem in running Hibernate Query
PostPosted: Thu Aug 23, 2007 12:48 am 
Newbie

Joined: Mon Aug 13, 2007 6:38 am
Posts: 16
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3



String str2 = "SELECT TO_CHAR(ADD_MONTHS( TO_DATE(?,'DD/MM/YYYY'), (ROWNUM-1))) as MONYR, ADD_MONTHS(TO_DATE(?,'DD/MM/YYYY'),(ROWNUM-1)) as DD_DATE FROM CL_Enroll as clEnroll WHERE ROWNUM <= MONTHS_BETWEEN(TO_DATE(?,'DD/MM/YYYY'),TO_DATE(?,'DD/MM/YYYY'))+1 ORDER BY ADD_MONTHS(TO_DATE(?,'DD/MM/YYYY'),(ROWNUM-1)) ASC";
try
{
String startDate = "5/8/2004";
String endDate= "20/12/2004";
List monyear = new ArrayList();
session1 = sessionFactory.openSession();
Query query = session1.createQuery(str2);
query.setString(0,startDate);
query.setString(1,startDate);
query.setString(2,endDate);
query.setString(3,startDate);
query.setString(4,startDate);
List query1 = query.list();

for(Iterator itr=query1.iterator();itr.hasNext();)
{
row = (Object[]) itr.next();
monyear.add(""+row[0]);
}
}


Full stack trace of any exception that occurs:
org.hibernate.QueryException: ( expected before ) in select [SELECT TO_CHAR(ADD_MONTHS(
TO_DATE(?,'DD/MM/YYYY'), (ROWNUM-1))) as MONYR, ADD_MONTHS(TO_DATE(?,'DD/MM/YYYY'),(ROWNUM-1))
as DD_DATE FROM com.cl.pojo.CL_Enroll as clEnroll WHERE ROWNUM <= MONTHS_BETWEEN(TO_DATE(?,'DD/MM/YYYY'),TO_DATE(?,'DD/MM/YYYY'))+1
ORDER BY ADD_MONTHS(TO_DATE(?,'DD/MM/YYYY'),(ROWNUM-1)) ASC]
at org.hibernate.hql.classic.SelectParser.token(SelectParser.java:118)
at org.hibernate.hql.classic.ClauseParser.token(ClauseParser.java:86)
at org.hibernate.hql.classic.ClauseParser.end(ClauseParser.java:113)
at org.hibernate.hql.classic.PreprocessingParser.end(PreprocessingParser.java:122)
at org.hibernate.hql.classic.ParserHelper.parse(ParserHelper.java:29)
at org.hibernate.hql.classic.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:191)
at org.hibernate.hql.classic.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:167)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:75)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:54)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1583)
at _jsp._clzone._reports._erp._common._locprodidshiber__jsp._jspService(/clzone/reports/erp/common/LocProdIdsHiber.jsp:176)
at com.caucho.jsp.JavaPage.service(JavaPage.java:75)
at com.caucho.jsp.Page.pageservice(Page.java:571)
at com.caucho.server.dispatch.PageFilterChain.doFilter(PageFilterChain.java:155)
at com.caucho.server.cache.CacheFilterChain.doFilter(CacheFilterChain.java:211)
at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:177)
at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:221)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:263)
at com.caucho.server.port.TcpConnection.run(TcpConnection.java:331)
at com.caucho.util.ThreadPool.runTasks(ThreadPool.java:464)
at com.caucho.util.ThreadPool.run(ThreadPool.java:408)
at java.lang.Thread.run(Thread.java:534)



Name and version of the database you are using:10g

So while running the above query in jsp , the server is Resin I am getiing the above specified Exception.
But when I run this query in Eclipse without using the server,it runs appropriately.
So what is the reason for this unpredictable behaviour, as I have to run this query in JSP only.
Some queries used to run properly in server but the above one is not working in JSP but is working fine with Eclipse.


Thanx in advance...
Regards,
Abhishek


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 23, 2007 1:51 am 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
Hi abhi,

Check you JDK version with eclipse and Resin .

_________________
Dharmendra Pandey


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 23, 2007 3:03 am 
Newbie

Joined: Mon Aug 13, 2007 6:38 am
Posts: 16
Hello,
Yes I have seen the Eclipse is using 1.4 and the Resin is also usinh the jdk1.4. But the same code works in eclipse but not in Resin.
So what to do.
Regards,
Abhishek


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 23, 2007 3:15 am 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
Check your jar in Resin or try to change query translator configuration may work not sure.

_________________
Dharmendra Pandey


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 23, 2007 3:56 am 
Newbie

Joined: Mon Aug 13, 2007 6:38 am
Posts: 16
Sorry, Not able to understand...Is there is no solution for this problem as I am stuck for now.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 23, 2007 5:05 am 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
I mean to say that check hibernate jar version in Resin in deployed application and in eclipse are same.

and changing query translator means change hibernate configuration

Code:
<prop key="hibernate.query.factory_class">
                  org.hibernate.hql.ast.ASTQueryTranslatorFactory
  </prop>

_________________
Dharmendra Pandey


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.