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.  [ 4 posts ] 
Author Message
 Post subject: Help with Criteria
PostPosted: Tue Oct 11, 2005 9:18 am 
Newbie

Joined: Wed Sep 28, 2005 11:07 am
Posts: 4
Location: Imola, Italy
I use Oracle db; in a table I have a DATE type field (myDate).
I don't have problem with O/R mapping but I need to implement, with Criteria, something that generates a query similar:

select TO_CHAR(myDate,'YYYY/MM/DD HH24'), count(*) from myTable
group by TO_CHAR(myDate,'YYYY/MM/DD HH24')


Do you have an idea about the solution with Criteria and Projection for this problem?


Thank you very much

Stefano


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 11, 2005 10:41 am 
Regular
Regular

Joined: Fri Sep 17, 2004 10:51 am
Posts: 61
Location: Rimini, Italy
Just a hint: look at Projections.sqlGroupProjection
I'd a quick look at the source and I think it can do wath you want, but I've never tried it.

_________________
--
Marco


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 12, 2005 4:22 am 
Newbie

Joined: Wed Sep 28, 2005 11:07 am
Posts: 4
Location: Imola, Italy
marco-p wrote:
Just a hint: look at Projections.sqlGroupProjection
I'd a quick look at the source and I think it can do wath you want, but I've never tried it.


Thank you very much Marco,
the sqlGroupProjection works correctly

Projections.sqlGroupProjection("to_char(myDate,'YYYY/MM/DD HH24') as myDate, count(*) as myCount", "to_char(myDate,'YYYY/MM/DD HH24')",
new String[]{"myDate", "myCount"" }, new Type[]{new StringType(), new ShortType() } ));

With Eclipse debug it wasn't so difficult to find the right syntax.

I'm from Imola, I didn't think that my problem's solution came so near to me.

Stefano


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 12, 2005 4:35 am 
Regular
Regular

Joined: Fri Sep 17, 2004 10:51 am
Posts: 61
Location: Rimini, Italy
Hey Stefano, I'm glad I've helped, especially a 'romagnolo' ! ;)
Please, don't forget to rate !

_________________
--
Marco


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