-->
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.  [ 3 posts ] 
Author Message
 Post subject: HQL that queries timestamps
PostPosted: Fri Apr 08, 2005 7:29 am 
Senior
Senior

Joined: Tue Aug 03, 2004 2:11 pm
Posts: 142
Location: Somerset
A quick question. I have a database table that stores a date of birth as a timestamp (yes, I know). If I want to do a query against that table, based on timestamp (e.g. find me records where the data of birth is 10/12/1978), then I get this:

Exception data: java.lang.UnsupportedOperationException: cannot perform lookups on timestamps

Now I've read other posts about this, and I knwo this worked in hibernate 2 and not in 3.

The question is, what is the work around for this ? Much as I'd like to, I can't change the database to store the date in a date field rather than a timestamp.


Hibernate version:

3 rc1


Full stack trace of any exception that occurs:
Exception data: java.lang.UnsupportedOperationException: cannot perform lookups on timestamps
at org.hibernate.type.TimestampType.getHashCode(TimestampType.java:99)
at org.hibernate.cache.QueryKey.hashCode(QueryKey.java:76)
at java.util.HashMap.hash(HashMap.java(Compiled Code))
at java.util.HashMap.getEntry(HashMap.java:423)
at java.util.LinkedHashMap.get(LinkedHashMap.java:285)
at net.sf.ehcache.store.MemoryStore.get(MemoryStore.java:171)
at net.sf.ehcache.Cache.searchInMemoryStore(Cache.java:257)
at net.sf.ehcache.Cache.get(Cache.java:220)
at org.hibernate.cache.EhCache.get(EhCache.java:110)
at org.hibernate.cache.StandardQueryCache.get(StandardQueryCache.java:74)
at org.hibernate.loader.Loader.list(Loader.java:1454)
at org.hibernate.hql.classic.QueryTranslatorImpl.list(QueryTranslatorImpl.java:879)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:782)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at org.springframework.orm.hibernate3.HibernateTemplate$21.doInHibernate(HibernateTemplate.java:657)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:310)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:643)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:635)
at net.targetgroup.broker.application.ApplicationDAOHibernate.matchApplication(ApplicationDAOHibernate.java:231)
at net.targetgroup.broker.application.applicationservices.ApplicationManagerBean.matchApplication(ApplicationManagerBean.java:295)
at

_________________
On the information super B road


Top
 Profile  
 
 Post subject: You may try to use the calendar type rahter than timestamp
PostPosted: Fri Apr 22, 2005 6:03 am 
Newbie

Joined: Fri Apr 22, 2005 4:33 am
Posts: 9
You can not search the fields with "timestamp" type because it did not support the getHashCode method. However, you can try to use the "calendar" type. I have no idea whether this solution is work for you or not but you can give it a try because there is no way to make it possible as long as you are using the timestamp type. You may refer to the entry http://forum.hibernate.org/viewtopic.php?p=2239206 to see how I resolved it in my case which is the case of trying to include a timestamp field in composite-id.


Top
 Profile  
 
 Post subject: Re: You may try to use the calendar type rahter than timesta
PostPosted: Fri Apr 22, 2005 4:46 pm 
Senior
Senior

Joined: Tue Aug 03, 2004 2:11 pm
Posts: 142
Location: Somerset
paxsonyang wrote:
You can not search the fields with "timestamp" type because it did not support the getHashCode method. However, you can try to use the "calendar" type. I have no idea whether this solution is work for you or not but you can give it a try because there is no way to make it possible as long as you are using the timestamp type. You may refer to the entry http://forum.hibernate.org/viewtopic.php?p=2239206 to see how I resolved it in my case which is the case of trying to include a timestamp field in composite-id.


Hi we resolved it by changing the database but thanks for the post anyway !

_________________
On the information super B road


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