-->
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: problem in generating HQL query
PostPosted: Thu Sep 20, 2007 5:10 am 
Newbie

Joined: Thu Sep 20, 2007 4:14 am
Posts: 1
Location: Whitefield,India
Guys I am new to hibernate. I am working on simple example.
I want to fetch the data from the table based on the date coloumn.

date format of the coloumn : 9/18/2007 12:37:14 AM


the Sql query look likes this :

select * from epat_login_info_tmp where to_date(login_time,'mm-dd-yy') = to_date(sysdate,'mm-dd-yy')

I want the HQL query which performs the same task as the above SQL query.

the HQL query i tried was:

from UserInfoVo uv where to_date(uv.loginDate,'dd-mm-yy') = to_date(sysdate,'dd-mm-yy')

but i get the below specified exception.can you tell me where is the mistake

I want to format the date coloumn in 'mm-dd-yy' format using HQL and reterive the data by sepecifing the date range.

pls help me on this.

Hibernate version:
hibernate0 - 3.0

Mapping documents:
<hibernate-mapping>
<class name="com.igate.vo.UserInfoVo" table="EPAT_LOGIN_INFO_TMP">
<id name="seqId" column="SEQ_ID" type="int"></id>
<property name="racfID" column="RACF_ID" type="string"/>
<property name="fname" column="FNAME" type="string"/>
<property name="lname" column="LNAME" type="int"/>
<property name="loginDate" column="LOGIN_TIME" type="date"/>
</class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
Date date = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
String toDate = formatter.format(date);
System.out.println("date"+toDate);
session= HibernateUtil.getSessionFactory().openSession();
Query q = session.createQuery("from UserInfoVo uv where to_date(uv.loginDate,'dd-mm-yy') = to_date(sysdate,'dd-mm-yy')");
List results = q.list();

Full stack trace of any exception that occurs:
java.lang.Exception: org.hibernate.exception.GenericJDBCException: could not execute query

Name and version of the database you are using:
oracle

The generated SQL (show_sql=true):


Debug level Hibernate log excerpt:


Problems with Session and transaction handling?

Read this: http://hibernate.org/42.ht[/b]

_________________
praveen


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.