Community
Participate
Working Groups
Build Identifier: eclipselink-2.3.0.v20110604-r9504 Using the entity: @Entity @Table(name="CUSTOMER_TABLE") public class Customer implements java.io.Serializable { // Instance variables private String id; private String name; public Customer() { } public Customer (String id, String name) { this.id = id; this.name = name; } @Id @Column(name="ID") public String getId() { return id; } public void setId(String v) { this.id = v; } @Column(name="NAME") public String getName() { return name; } public void setName(String v) { this.name = v; } } ---------------------- Using the client code: CriteriaBuilder qbuilder = getEntityManagerFactory().getCriteriaBuilder(); CriteriaQuery cquery = qbuilder.createQuery(); Root<Customer> customer = cquery.from(Customer.class); System.out.println("Creating select using selection items with the same alias"); try { cquery.select(qbuilder.array(customer.get("id").alias("SAMEALIAS"), customer.get("name").alias("SAMEALIAS"))); System.out.println("Did not thrown IllegalArgumentException"); pass = false; } catch (IllegalArgumentException iae) { System.out.println("received expected IllegalArgumentException"); } catch (Exception e) { pass = false; System.out.println("Received unexpected exception", e); } ---------------------- output: [Creating select using selection items with the same alias Did not thrown IllegalArgumentException Reproducible: Always
The following client code also has the same issue: CriteriaBuilder qbuilder = getEntityManagerFactory().getCriteriaBuilder(); CriteriaQuery cquery = qbuilder.createQuery(); Root<Customer> customer = cquery.from(Customer.class); System.out.println("Creating select using selection items with the same alias"); try { CompoundSelection<java.lang.Object[]> c = qbuilder.array(customer.get("id").alias("SAMEALIAS"), customer.get("name").alias("SAMEALIAS")); cquery.select(c); System.out.println("Did not thrown IllegalArgumentException"); pass = false; } catch (IllegalArgumentException iae) { System.out.println("received expected IllegalArgumentException"); } catch (Exception e) { pass = false; System.out.println("Received unexpected exception", e); }
Updating target milestone.
Created attachment 223420 [details] proposed fix and test case
*** Bug 366261 has been marked as a duplicate of this bug. ***
Fix checked into main
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink