-->
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: Can I write count(distinct po.compositeId) in hql?
PostPosted: Tue Sep 07, 2004 10:44 pm 
Beginner
Beginner

Joined: Thu Jul 22, 2004 4:32 am
Posts: 31
Can I write count(distinct po.compositeId) in hql?

when I do this, Hibernate reports a error:

net.sf.hibernate.QueryException: path expression ends in a composite value: collection1_.id [
select count(distinct collectionPO.id) from gov.ntcri.domain.po.collection.CollectionCreatorPO as creatorPO join creatorPO.collectionPO as collectionPO where creatorPO.creatorName like '%%'and collectionPO.isDeleted=0]
at net.sf.hibernate.hql.PathExpressionParser.getWhereColumn(PathExpressionParser.java:375)
at net.sf.hibernate.hql.SelectParser.token(SelectParser.java:160)
at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87)
at net.sf.hibernate.hql.ClauseParser.end(ClauseParser.java:114)
at net.sf.hibernate.hql.PreprocessingParser.end(PreprocessingParser.java:143)
at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:30)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:149)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:138)
at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:293)
at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1561)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1532)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
at com.dsii.common.hibernate.HibernateUtils.getCount(HibernateUtils.java:297)
at gov.ntcri.domain.dao.collection.CollectionDAO.searchByCollectionCreatorName(CollectionDAO.java:301)
at gov.ntcri.domain.dao.collection.CollectionDAO.main(CollectionDAO.java:311)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 08, 2004 12:07 am 
Newbie

Joined: Wed Sep 01, 2004 1:32 pm
Posts: 9
Location: (eastern) North Carolina
Looks like you are doing sql not hql.

Why not get Hibernate session, then get reference to its' Connection then do straight jdbc via Statement.executeQuery() and pull the count(distinct) total from first row of ResultSet?


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.