-->
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.  [ 1 post ] 
Author Message
 Post subject: How to convert "String" into "Date type"
PostPosted: Tue Aug 21, 2007 7:01 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 str1 = "select to_char(to_date('1-8-2005','dd-mm-yyyy'),'dd-Mon-yyyy') as date1, to_char(to_date('1/8/2004','dd-mm-yyyy'),'dd-Mon-yyyy') as date2" from dual;

try
{
session1 = sessionFactory.openSession();
List list = session1.createQuery(str1).list();

for(Iterator itr=list.iterator();itr.hasNext();)
{
row = (Object[]) itr.next();
date1 += ""+row[0];
date2 += ""+row[1];
}
}


org.hibernate.QueryException: , expected in SELECT [select to_char(to_date('1-8-2005','dd-mm-yyyy'),'dd-Mon-yyyy')
as date1, to_char(to_date('1/8/2004','dd-mm-yyyy'),'dd-Mon-yyyy') as date2]
at org.hibernate.hql.classic.SelectParser.token(SelectParser.java:175)
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:96)
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:177)
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:Oracle 10g



So in the above code , I am trying to convert String type date into Date Type and trying to use the dual table.
But Hibernate is not able to find the dual table as a mapped table, so giving such an error.

So in order to execute such type of queries, what procedure we should follow.
Thanx in advance,

Regards,
Abhishek


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

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.