Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 1111706 - [GSS](6.3.0) NonUniqueDiscoveredSqlAliasException: Encountered a duplicated sql alias
[GSS](6.3.0) NonUniqueDiscoveredSqlAliasException: Encountered a duplicated s...
Status: CLOSED WONTFIX
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Hibernate (Show other bugs)
6.1.0
Unspecified Unspecified
unspecified Severity unspecified
: ---
: EAP 6.3.0
Assigned To: Gail Badner
Martin Simka
Russell Dickenson
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2014-06-20 15:03 EDT by Stephen Fikes
Modified: 2014-10-25 08:01 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Known Issue
Doc Text:
In this release of JBoss EAP 6 a native SQL query which specifies a column multiple times without unique aliases (e.g. "select e.id, e.title, e.id from Event e") for any simple entity (e.g. Event) fails in with the following message: ---- org.hibernate.loader.custom.NonUniqueDiscoveredSqlAliasException: Encountered a duplicated sql alias [id] during auto-discovery of a native-sql query ---- This happens because Hibernate obtains the column labels from java.sql.ResultSetMetaData.getColumnLabel(). Hibernate cannot determine if the columns with the same name refer to the same value from the same entity. Rather than possibly making an incorrect assumption, Hibernate throws the exception. The workaround is to provide unique aliases for columns with the same name (e.g. "select e.id AS id1, e.title, e.id AS id2 from Event e").
Story Points: ---
Clone Of:
Environment:
Last Closed: 2014-08-11 15:07:03 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Maven based test (3.52 KB, application/x-gzip)
2014-06-20 15:03 EDT, Stephen Fikes
no flags Details

  None (edit)
Description Stephen Fikes 2014-06-20 15:03:43 EDT
Created attachment 910870 [details]
Maven based test

Description of problem:
For any simple entity (e.g. Event) a native SQL query which specifies a column multiple times (e.g. "select e.id, e.title, e.id from Event e") fails in Hibernate 4:

org.hibernate.loader.custom.NonUniqueDiscoveredSqlAliasException: Encountered a duplicated sql alias [id] during auto-discovery of a native-sql query

Version-Release number of selected component (if applicable):
Hibernate 4

How reproducible:
Consistently

Steps to Reproduce:
For a simple entity, execute a native SQL query specifying one column (e.g. 'id') multiple times
	List results = session.createSQLQuery(
		"select e.id, e.title, e.id from Event e").list();

Actual results:
org.hibernate.loader.custom.NonUniqueDiscoveredSqlAliasException: Encountered a duplicated sql alias [id] during auto-discovery of a native-sql query
	at org.hibernate.loader.custom.CustomLoader.autoDiscoverTypes(CustomLoader.java:630)
	at org.hibernate.loader.Loader.getResultSet(Loader.java:2039)
	at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1832)
	at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1811)
	at org.hibernate.loader.Loader.doQuery(Loader.java:899)
	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:341)
	at org.hibernate.loader.Loader.doList(Loader.java:2516)
	at org.hibernate.loader.Loader.doList(Loader.java:2502)
	at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2332)
	at org.hibernate.loader.Loader.list(Loader.java:2327)
	at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:338)
	at org.hibernate.internal.SessionImpl.listCustomQuery(SessionImpl.java:1826)
	at org.hibernate.internal.AbstractSessionImpl.list(AbstractSessionImpl.java:231)
	at org.hibernate.internal.SQLQueryImpl.list(SQLQueryImpl.java:157)
	...

Expected results:
The exception is not expected.

Additional info:
- The same query works as late as in Hibernate 3.3.2.GA.
- Modifying the query to use explicit column aliases works around the issue:
	"select e.id as eid1, e.title, e.id as eid2 from Event e"
Comment 2 Gail Badner 2014-06-23 16:06:11 EDT
This is an expected failure due to HHH-5992. The workaround is the appropriate way to deal with this.

Note You need to log in before you can comment on or make changes to this bug.