【问题标题】:JPA SqlResultSetMapping object orderJPA SqlResultSetMapping 对象顺序
【发布时间】:2018-01-20 14:38:09
【问题描述】:

JPA:如果在@SqlResultSetMapping 中定义了类、实体和列,那么返回对象的顺序是什么?

@SqlResultSetMapping(
       name="CustomerDetailsResult",
       classes={
          @ConstructorResult(
               targetClass=com.example.Customer.class,
                 columns={
                    @ColumnResult(name="id"),
                    @ColumnResult(name="name"),
                 }
          )
       },
       entities={ 
            @EntityResult(entityClass=com.example.Order.class, fields={
                @FieldResult(name="id", column="order_id"),
                @FieldResult(name="quantity", column="order_quantity"), 
                @FieldResult(name="item", column="order_item")})},
        columns={
            @ColumnResult(name="item_name")}
      )

结果行是 Object[]{customer, order, scalar_value} 或 Object[]{order, scalar_value, customer} 等。

【问题讨论】:

  • 你是指查询中调用getResultList()后的行中列的顺序还是List中行的顺序?
  • 对象在一行中的顺序。

标签: jpa sqlresultsetmapping


【解决方案1】:

结果将包含您在@SqlResultSetMapping 中定义的对象。

在你的情况下:

Object[]{customer, order, scalar_value}

【讨论】:

    猜你喜欢
    • 2021-11-23
    • 1970-01-01
    • 2017-01-07
    • 2020-06-26
    • 1970-01-01
    • 2018-03-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多