In EclipseLink 2.5 (JPA 2.1), I'm trying to map the results of a native query to a POJO, which according to these links should be possible:
- JPA : How to convert a native query result set to POJO class collection
- http://www.eclipse.org/eclipselink/api/2.5/javax/persistence/ConstructorResult.html
...using this syntax (taken straight from EclipseLink 2.5 api docs):
Query q = em.createNativeQuery(
"SELECT c.id, c.name, COUNT(o) as orderCount, AVG(o.price) AS avgOrder " +
"FROM Customer c, Orders o " +
"WHERE o.cid = c.id " +
"GROUP BY c.id, c.name",
"CustomerDetailsResult");
@SqlResultSetMapping(
name="CustomerDetailsResult",
classes={
@ConstructorResult(
targetClass=com.acme.CustomerDetails.class,
columns={
@ColumnResult(name="id"),
@ColumnResult(name="name"),
@ColumnResult(name="orderCount"),
@ColumnResult(name="avgOrder", type=Double.class)
}
)
}
)
However, the "classes" attribute of the @SqlResultSetMapping is not found. I tried with Eclipselink 2.5.2, and 2.6. Is there another (optional) EclipseLink jar I must use to get that functionality?