缺少EclipseLink @SQLResultSetMapping到POJO

时间:2015-03-27 17:31:25

标签: jpa eclipselink sqlresultsetmapping

在EclipseLink 2.5(JPA 2.1)中,我正在尝试将本机查询的结果映射到POJO,根据这些链接应该是可能的:

...使用这种语法(直接来自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)
                    }
          )
       }
      )

但是,找不到@SqlResultSetMapping的“classes”属性。我尝试使用Eclipselink 2.5.2和2.6。我必须使用另一个(可选的)EclipseLink jar来获得该功能吗?

0 个答案:

没有答案