If I have a Foo object that looks something like this:
@Entity
public final class Foo {
private int id;
private String name;
...
}
I want to get the names of Foo objects with an identifier greater than 10. If I already have a collection of Foo objects, I can do something like this:
List<Foo> foos = ...
Query filter = session.createFilter(foos, "where id > :id");
filter.setInteger("id", 10);
List filteredFoos = filter.list();
Is there a way to create the above filter so that I can get a list of strings (i.e. Foo names) instead of a Foos list that I would have to manually filter out like this:
for (Foo foo : filteredFoos) {
String name = foo.getName();
...
}
source
share