Maybe to name the methods more in JDK manner:
QueryStream<Event> query = session.createQueryStream(Event.class);
query.where(e -> e.getType() == "Java 8")
.orderBy(e -> e.getCreateDate());
List<Event> list = query.list();
List<Event> list = query.stream()
.filter(e -> ...)
.map(e -> ...)
.collect(toList());
Optional<Event> optional = query.setMaxResults(1).getOptional();
Event event = query.setMaxResults(1).getOptional().orElse(null);
Generally what would be needed is a bytecode to SQL translator. The intial version could have been limited to handle simple comparision statements:
entity.(field|getter) op value
Where op could be:
And additionally the and (&&) and or (||) operators.
And latter on the syntax could be extended to allow method calls etc.
|