Bug 1057742

Summary: PostgreSQL & H2 dialect incorrect for count distinct tuples for composite attributes
Product: [JBoss] JBoss Enterprise Application Platform 6 Reporter: Stephen Fikes <sfikes>
Component: HibernateAssignee: Brett Meyer <brmeyer>
Status: CLOSED CURRENTRELEASE QA Contact: Zbyněk Roubalík <zroubali>
Severity: medium Docs Contact: Russell Dickenson <rdickens>
Priority: medium    
Version: 6.1.1CC: kkhan, msimka, sfikes, smumford, theute
Target Milestone: DR2   
Target Release: EAP 6.3.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
JBoss EAP 6 has been updated to allow the use of parentheses around composite attribute lists in count-distinct queries in MySQL and other databases. This was not allowed in previous versions of the product and would result in an exception being thrown for PostgreSQL. This release allows the Dialect to use the parentheses as appropriate without throwing an exception.
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-06-28 15:37:09 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On:    
Bug Blocks: 1063408    
Attachments:
Description Flags
Simple pure Hibernate Maven JUnit test none

Description Stephen Fikes 2014-01-24 17:34:49 UTC
Created attachment 855112 [details]
Simple pure Hibernate Maven JUnit test

Description of problem:
When a composite key is used a "select count (distinct <entity_type>)" query fails to enclose the column names that make up the key attribute in parenthesis and the following exception is raised:


org.hibernate.exception.SQLGrammarException: could not extract ResultSet
	...
Caused by: org.postgresql.util.PSQLException: ERROR: function count(character varying, character varying) does not exist
  Hint: No function matches the given name and argument types. You might need to add explicit type casts.
  Position: 8

Version-Release number of selected component (if applicable):
EAP 6.1.1 and Hibernate 4.2.0.SP1

How reproducible:
Consistently

Steps to Reproduce:
1. Using Hibernate core libraries that include the fix for https://hibernate.atlassian.net/browse/HHH-7165 (introduced in Hibernate 4.1.2), create an entity with a composite key
2. Issue a "select count (distinct <entity_type>)" query

Actual results:
Raises exception above

Expected results:
Should return a numeric count

Additional info:
https://hibernate.atlassian.net/browse/HHH-8864

Comment 1 Brett Meyer 2014-01-25 05:44:51 UTC
Corrected upstream and will be a part of the EAP 6.3 component upgrade.

Comment 2 Kabir Khan 2014-04-04 15:28:15 UTC
Fixed by upgrade -> ON_QA

Comment 3 Martin Simka 2014-04-17 13:28:26 UTC
verified on EAP 6.3.0.ER1