Community
Participate
Working Groups
Using inheritance strategy "JOINED" on entities with composite primary keys produces wrong SQL for some queries. The produced SQL may contain duplicate names. This diff fixes the bug: Index: org/eclipse/persistence/descriptors/InheritancePolicy.java =================================================================== --- org/eclipse/persistence/descriptors/InheritancePolicy.java (revision ) +++ org/eclipse/persistence/descriptors/InheritancePolicy.java (revision ) @@ -132,8 +132,13 @@ // allTables should've been null, too allTables = new Vector(getDescriptor().getTables()); } + //Bugfix: Prevent duplicate names in JOIN + if(! childrenTables.contains(table)){ - childrenTables.add(table); + childrenTables.add(table); + } + if(! allTables.contains(table)){ - allTables.add(table); + allTables.add(table); + } childrenTablesJoinExpressions.put(table, expression); childrenJoinExpression = expression.and(childrenJoinExpression); }
Same bug in Eclipselink 2.0.2
Can you please provide an example query and the resulting SQL?
The attached test code executes: JPQL: em.createQuery("select h from HerkunftDetail h where h.zuordnungsmerkmal='A'") .setHint(QueryHints.LEFT_FETCH, "h.vorgang") .getResultList(); The resulting SQL: SELECT t5.ID, t5.LEISTUNGSEMPFAENGER, t5.ZUORDNUNGSMERKMAL, t5.DETAILID, t5.BUCHUNGSKONTO, t5.VORGANG_ID, t0.ID, t0.LEISTUNGSEMPFAENGER, t0.DTYPE, t0.LEISTUNGSINANSPRUCHNAHMEBIS, t0.LEISTUNGSINANSPRUCHNAHMEVON, t1.ID, t1.LEISTUNGSEMPFAENGER, t1.AUFANFORDERUNG, t3.ID, t3.LEISTUNGSEMPFAENGER, t3.EXTERNEREFERENZ FROM HerkunftDetailX t5 LEFT OUTER JOIN (LeistungsvorgangX t0 LEFT OUTER JOIN LeistungsantragX t1 ON (t1.LEISTUNGSEMPFAENGER = t0.LEISTUNGSEMPFAENGER) LEFT OUTER JOIN LeistungsantragX t1 ON (t1.LEISTUNGSEMPFAENGER = t0.LEISTUNGSEMPFAENGER) LEFT OUTER JOIN LeistungsfallX t3 ON (t3.LEISTUNGSEMPFAENGER = t0.LEISTUNGSEMPFAENGER) LEFT OUTER JOIN LeistungsfallX t3 ON (t3.LEISTUNGSEMPFAENGER = t0.LEISTUNGSEMPFAENGER)) ON ((t0.id = t5.VORGANG_ID) AND (t0.leistungsempfaenger = t5.LEISTUNGSEMPFAENGER)), LeistungsfallX t4, LeistungsantragX t2 WHERE (t5.ZUORDNUNGSMERKMAL = ?)
Created attachment 174000 [details] Code to reproduce the bug
I think this was fixed in 2.1, was the latest version tried?
(In reply to comment #5) > I think this was fixed in 2.1, was the latest version tried? Last version checked: 2.0.2 I tested again with 2.1 and can confirm that the bug is fixed. Will we see a backport for 1.2 ?
Setting to fixed based on above comments. Currently there are no plans to backport to 1.2. There has been a major release and several minor releases since 1.2 and the inclusion list for the next 1.2 patch is intentionally very limited.
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink