ObjectDB ObjectDB

Retrieve latest entry in a time-series


As mentioned elsewhere, subqueries are not currently supported.  A subquery is the way that seems recommended to get only the latest entry in a time series (e.g. the latest time-clock entry for all employees).  

Is there an ObjectDB way to get the latest entry in a series?  


The easiest solution is to order the results by date in descending order:

    SELECT FROM MyEntity e WHERE ... ORDER BY e.date DESC

Then you can run the query with a request to return the first result only:

    return em.createQuery("...").setMaxResults(1).getSingleResult();
ObjectDB Support


To post on this website please sign in.