-->
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: HQL query on Joda DateTime field in table not working
PostPosted: Thu Jun 20, 2013 8:32 am 
Newbie

Joined: Thu Jun 20, 2013 8:29 am
Posts: 1
I am trying to perform an HQL query on a joda date time field in a table and its not giving any results.

The date is stored in MySQL database as 2013-06-13 05:00:00 However in my method below, after the dateTime.toDate() is called, its going to the db as Thu Jun 13 00:00:00 CDT 2013. If I don't do the .date conversion, the method complains that a date is required.

Products is my table name

impactTime is my pojo field and table column name

Also tried query.setTimestamp("impactTime", dateTime.toDate()); but that did not work either.

Please advice.

I am calling the method below -
Code:
public List<String> getAllIds(final DateTime dateTime) {
   Query query =
        getSession().createQuery(
            "select id from Products where impactTime = :impactTime");
    query.setDate("impactTime", dateTime.toDate());

    return query.list();
         }


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.