How to get the entity with the newest date

google-app-engine, google-cloud-datastore, objectify

Solution

You just have to add a minus in front of "date" in your order :

`List<Transaction> fetched2 = ofy.query(Transaction.class).filter("someproperty", somepropertyvalue).order("-date").list();`

That should return you a list of Transaction with the newest one in first position.

Problem

Does anyone have any idea how to retrieve the last(with the newest date) entity in objectify? I know how to make a query but how to retrieve the one with the newest date? ``` List<Transaction> fetched2 = ofy.query(Transaction.class).filter("someproperty", somepropertyvalue).order("date").list(); ``` I could try to bubble sort it but I´m sure there is an easier way. THX

Original source