-->
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 And Dates
PostPosted: Wed Sep 07, 2005 8:28 am 
Newbie

Joined: Thu May 19, 2005 11:50 pm
Posts: 10
I'm using Hibernate 3 and I want to write HQL to group data by month but I have no idea how to do this and would prefer to not use native SQL. Here's an example, if I have this table...

MEMBER
id name registeredDate
1 aaa 05-14-2005 14:03:01
2 bbb 04-19-2003 19:09:16
3 ccc 05-27-2005 08:30:42
4 ddd 11-13-2004 11:59:03

I want to get all the users who have registered within the past 12 months and then a count of those users. I know in HQL I can add a clause like this and registeredDate >= :regDateToTest and just populate "regDateToTest" in java. That would give me those registered dates from the past year. However, I then have to do a bunch of date manipulation and checking inside my action to do the group by piece. I'm wondering if there's simply an easier way to do this but, again, without using native SQL queries.

[/b]


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.