-->
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.  [ 6 posts ] 
Author Message
 Post subject: how to find count on distinct object
PostPosted: Wed Apr 21, 2004 4:57 pm 
Newbie

Joined: Thu Oct 16, 2003 7:55 pm
Posts: 4
Hi,

I have a named query like this.

SELECT
distinct new com.radian.axiom.billing.cuw.bo.dto.BillingProfileSummaryDTO( summaryDTO.billingProfileID,summaryDTO.billingProfileDisplayID,
summaryDTO.customerID)
FROM
com.radian.axiom.billing.cuw.bo.dto.BillingProfileSummaryDTO AS summaryDTO
WHERE
((:customerNameFlag = 0) OR (UPPER(summaryDTO.customerName) LIKE UPPER(:customerName)))
AND
((:branchNameFlag = 0) OR (UPPER(summaryDTO.coveredBranchName) LIKE UPPER(:branchName)))

here i need to find the count of these distinct new records.

Let me know the solution if any body knows. I am using oracle 9i and hibernate 2.1

Sunil


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 22, 2004 3:07 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
count(distinct ...)

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 22, 2004 3:39 pm 
Newbie

Joined: Thu Oct 16, 2003 7:55 pm
Posts: 4
i did it but i am getting this exception now

net.sf.hibernate.QueryException: alias or expression expected in SELECT [

if i use
select count(distinct new Object(...,...)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 22, 2004 3:51 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Oh,
why creating new objects when you want to have a count. I don't expect Hibernate to support that.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 22, 2004 4:25 pm 
Newbie

Joined: Thu Oct 16, 2003 7:55 pm
Posts: 4
i have a requirement where in i need to consider 6 columns to form a distinct record and i want to count those distinct records. You are right I don't need to create an object for counting


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 22, 2004 4:45 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
actually count( distinct a.name, a.value) won't work either. But I can't tell if this is a bug or if it's expected.

_________________
Emmanuel


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