How to get all entities using JPAContainer?

Hi,

I have a JPAContainer. How can I get all customers from the database using JPAContainer as a List?


List<Customer> customers = new ArrayList<Customer>();
for (int id : container.getItemIds()) {
   customers.add(container.getItem(id).getEntity());
}

Also, another goal is to iterate and sum up a specific property, for example customer.getDebts(); to have a final sum of open payments over all customers.

I would therefore use the same code as above, but just append a

debitSum += container.getItem(id).getEntity().getDebts();

Am I overcomplicating things here?