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 = em.getCriteriaBuilder(); System.out.println("Testing multiselect selection[]"); cquery = qbuilder.createTupleQuery(); if (cquery != null) { System.out.println("Obtained Non-null Criteria Query"); Root<Customer> customer = cquery.from(Customer.class); System.out.println("Creating multiselect using selection array of items with the same alias"); Selection[] selection = {customer.get("id").alias("SAMEALIAS"), customer.get("name").alias("SAMEALIAS")}; try { cquery.multiselect(selection); System.out.println("Did not thrown IllegalArgumentException"); } catch (IllegalArgumentException iae) { System.out.println("received expected IllegalArgumentException"); } catch (Exception e) { System.out.println("Received unexpected exception", e); } } System.out.println("Testing multiselect List"); cquery = qbuilder.createTupleQuery(); if (cquery != null) { System.out.println("Obtained Non-null Criteria Query"); Root<Customer> customer = cquery.from(Customer.class); System.out.println("Creating multiselect using selection items with the same alias"); try { List list = new ArrayList(); list.add(customer.get("id").alias("SAMEALIAS")); list.add(customer.get("name").alias("SAMEALIAS")); cquery.multiselect(list); System.out.println("Did not thrown IllegalArgumentException"); } catch (IllegalArgumentException iae) { System.out.println("received expected IllegalArgumentException"); } catch (Exception e) { System.out.println("Received unexpected exception", e); } } --------- output: Testing multiselect selection[] Obtained Non-null Criteria Query Creating multiselect using selection array of items with the same alias Did not thrown IllegalArgumentException Testing multiselect List Obtained Non-null Criteria Query Creating multiselect using selection items with the same alias Did not thrown IllegalArgumentException Reproducible: Always
Updating target milestone.
*** This bug has been marked as a duplicate of bug 366386 ***
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink