0
votes

Here is there is such a task:

int sum = controller.getStore().boxFor(A.class).query().property(A_.field1).sum()+ 
controller.getStore().boxFor(A.class).query().property(A_.field2).sum()

Can this be done with a single query against the database? If possible, how? Thanks a lot!

1

1 Answers

0
votes

Two sums, two DB queries, but one Query object:

Query<A> query = controller.getStore().boxFor(A.class).query().build();
int sumSum = query.property(A_.field1).sum() + query.property(A_.field2).sum()