query.select(from);
Subquery<Number> subquery = query.subquery(Number.class);
Root maxTime = subquery.from(JPAObject.class);
subquery.select(criteriaBuilder.max(maxTime.get("timestamp")));
Predicate subPredicate1 = criteriaBuilder.le(maxTime.get("timestamp"), timestamp);
Predicate subPredicate2 = criteriaBuilder.equal(maxTime.get("oid"), from.get("oid"));
subquery.where(criteriaBuilder.and(subPredicate1, subPredicate2));
Predicate predicate1 = criteriaBuilder.equal(from.get("timestamp"), subquery);
Predicate predicate2 = criteriaBuilder.notEqual(from.get("isDeleted"), Boolean.TRUE);