| Summary: |
CriteriaQuery.multiselect() does not throw IllegalArgumentException if more than one selection item has the same assigned alias |
| Product: |
z_Archived
|
Reporter: |
Stephen DiMilla <stephen.dimilla> |
| Component: |
Eclipselink | Assignee: |
Nobody - feel free to take it <nobody> |
| Status: |
CLOSED
DUPLICATE
|
QA Contact: |
|
| Severity: |
blocker
|
|
|
| Priority: |
P3
|
CC: |
christopher.delahunt, lance.andersen, stephen.dimilla, tom.ware
|
| Version: |
unspecified | |
|
| Target Milestone: |
--- | |
|
| Hardware: |
Macintosh | |
|
| OS: |
Mac OS X - Carbon (unsup.) | |
|
| Whiteboard: |
|
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