-->
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: Hibernate criteria group by date as month
PostPosted: Fri May 11, 2012 8:18 am 
Newbie

Joined: Fri May 11, 2012 7:22 am
Posts: 1
Hi,

i am facing the issue with group by in hibernate criteria. i stored date field values in db like this

val_dt
-------
15-05-12
15-05-12
20-05-12
20-05-12

I need to get group by using "month" but not by date. when i am executing the below code i am getting the below issue.

getPostDatedChequeSummary(PDCEnquiryInfo info)
{

List<String> acctList = info.getAccountNumber();
List<String> custList = info.getCustomerId();

Criteria criteria =session.createCriteria(FbpPostDtdCheq.class);
criteria.add(Restrictions.in("id.custId", custList)); -----> here i am passing multiple customer id values
criteria.add(Restrictions.between("valDt", fromDate, toDate));
criteria.add(Restrictions.in("fbpOwnAcct.id.acctId", acctList));
List<String> acctList = info.getAccountNumber();


criteria.setProjection(Projections.sqlGroupProjection(
"month({alias}.val_dt) as month", "month({alias}.val_dt)",
new String[] {"month"}, new Type[] {Hibernate.STRING}));



criteria.setProjection(projectionList);

}


when i am executing the above code i am getting the below error :

Caused by: java.sql.SQLSyntaxErrorException: ORA-00904: "MONTH": invalid identifier

at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:440)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:837)


please give me suggestion....


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.