-->
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: re: join criteria with group
PostPosted: Mon Mar 26, 2012 9:53 pm 
Newbie

Joined: Tue Dec 13, 2011 8:05 pm
Posts: 2
Hi
How can I write following SQL

Code:
SELECT
m.match_type,
count(m.match_type)
cat.description,
loc.oid

FROM
USER_MATCH m,
RECORD rec,
CATEGORY cat,
LOCATION loc

WHERE
m.record_oid = rec.oid and
rec.category_oid = cat.oid and
rec.location_oid = loc.oid
group by m.match_type, cat.description, loc.oid


in hibernate criteria?

I have attempt it as following but I'm getting
subquery expressions not allowed here error.

Code:
Criteria criteria = hibernateTemplate.getSessionFactory().getCurrentSession().createCriteria(Match.Class);
        criteria.createAlias("record", "record");
        criteria.createAlias("category", "category");
       
        ProjectionList projList = Projections.projectionList();       
        projList.add(Projections.groupProperty("record.categoryId")); 
        projList.add(Projections.groupProperty("record.locationId"));
        criteria.setProjection(projList);


thanks in advance :)


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.