Bug 1402311

Summary: Same column returned with multiple aliases in scalar query
Product: [JBoss] JBoss Enterprise Application Platform 6 Reporter: Tom Ross <tom.ross>
Component: Hibernate, JPAAssignee: Gail Badner <gbadner>
Status: CLOSED NOTABUG QA Contact: Martin Simka <msimka>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.3.3CC: bmaxwell, gbadner, msimka, smarlow, tom.ross
Target Milestone: ---Flags: gbadner: needinfo? (tom.ross)
Target Release: EAP 6.4.14   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-02-20 14:42:11 UTC Type: Enhancement
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Tom Ross 2016-12-07 08:49:50 UTC
In the case of a relation "OneToMany" between two JPA entities, when we make a search on the parent entity, the generated SQL presents duplicated fields. Hele is an example :

                select 
                               school0_.ID as ID1_0_0_,
                               students1_.ID as ID1_1_1_,
                               school0_.NAME as NAME2_0_0_,
                               school0_.ZIP_CODE as ZIP_CODE3_0_0_,
                               students1_.FNAME as FNAME2_1_1_,
                               students1_.LNAME as LNAME3_1_1_,
                               students1_.SCHOOL_ID as SCHOOL_I4_0_0__,
                               students1_.ID as ID1_1_0__ 
                from 
                               SCHOOL school0_ 
                inner join 
                               STUDENT students1_ 
                on 
                               school0_.ID=students1_.SCHOOL_ID 
                where 
                               school0_.ZIP_CODE=? 
                order by 
                               school0_.ID

in more complicated cases, there can be more than two duplicated fields. Although the duplication of fields doesn't distort perfromance at a DB level, this problem is critical for us regarding network performances. We are indeed making hundred millions of queries a year.

Comment 6 Brad Maxwell 2017-02-20 14:42:11 UTC
Closing as this is an RFE , there is an upstream open for it https://hibernate.atlassian.net/browse/HHH-11313