-->
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.  [ 2 posts ] 
Author Message
 Post subject: Custom UserType with 2 Columns
PostPosted: Wed Sep 29, 2010 10:10 am 
Newbie

Joined: Fri Mar 06, 2009 11:22 am
Posts: 16
I have a custom UserType with 2 columns defined but when trying to query the object it seems that hibernate is building a query which is invalid.

My UserType has 2 columns a timestamp and an int (for capturing milliseconds) in MySQL. When attempting to do an HQL DateRange Query I do the following:

select count(a) from Entity a where a.time Between "2010-10-10 12:12:00" and "2010-10-11 12:12:00"

but Hibernate is generating

select count(a) from Entity a where (a.time a.ms) Between "2010"10'10 12:12:00" and "2010-10-11 12:12:00" which complains that two columns are defined in the between query where it is only expecting 1. What am I doing wrong?


Top
 Profile  
 
 Post subject: Re: Custom UserType with 2 Columns
PostPosted: Wed Sep 29, 2010 10:25 pm 
Beginner
Beginner

Joined: Fri Mar 11, 2005 7:46 am
Posts: 29
I suggest using your UserType in HQL, eg.

Code:
BETWEEN new UserType(val1, val2) and new UserType(valA1, valA2) 


Also, try turning on SQL tracing so you can verify generated SQL easier.


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