Sorting Entity Instances

Sorting Entity Instances

Often, you want to retrieve multiple instances of a given entity and list them in a particular order. The service.xml file lets you specify the default order of your entities.

Suppose you want to return entities by their creation date. It’s easy to specify these default orderings:

    <order-column name="createDate" order-by="desc" />

You can enter asc or desc for ascending or descending order.

Now you know how to order your service entities.