If I have an entity called Foo that looks a little like this:
@Entity
public final class Foo {
private int id;
private String name;
...
}
I want to retrieve the names of the Foo objects that have an id greater than 10. If I already have a collection of Foo objects, I could 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 such that I would retrieve a list of Strings (i.e. the Foo names) instead of the list of Foos which I would have to manually filter out like so:
for (Foo foo : filteredFoos) {
String name = foo.getName();
...
}