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}等。
答案 0 :(得分:0)
结果将包含您在@SqlResultSetMapping中定义的对象。
在你的情况下:
for (int i = 0; i < obj.length(); i++) {
//getting the json object of the particular index inside the array
JSONObject heroObject = obj.getJSONObject(i);
String aka=heroObject.getString("your key here");
}