1

次のクラスがあるとします

@Entity
public class Customer extends Model {

    @Id
    public int id;
    public String email;
    @ManyToOne
    public List<Order> orders;
    public HashMap<String, Object> additionalData;

    public static Finder<String, Customer> find = new Finder<String, Customer>(String.class, Customer.class);

    public static List<Customer> getCustomersWithOpenOrders(){
        return find
                .fetch("orders")
                // with "order.state = 'open'" count > 0
                // add total sum of all orders to 'additionalData' collection
                .findList();
    }
}

すべての注文の合計をadditionalDataコレクションに保存する方法は?

4

1 に答える 1