0

JPA: if classes, entities and columns are defined in @SqlResultSetMapping, what is the order of objects returned?

@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")}
      )

The result row is Object[]{customer, order, scalar_value}, or Object[]{order, scalar_value, customer}, etc.

2
  • Do you mean the order of the columns in the row or the order of the rows in the List after calling getResultList() on the query? Commented Jan 22, 2018 at 14:47
  • the order of objects in a row. Commented Jan 22, 2018 at 17:33

1 Answer 1

0

The result will contain the object as you defined it in the @SqlResultSetMapping.

In your case:

Object[]{customer, order, scalar_value}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.