Of course it's possible. You can use a SELECT clause:
Code:
Query query = session.createQuery( "select firstname, lastname from Person" )
That gives you the first and last names of all persons, but not the persons' other attributes. When you call query.list(), you'll get a list of array objects, which you can iterate like this:
Code:
List results = query.list();
for (Iterator it = results.iterator(); it.hasNext(); ) {
Object[] myResult = (Object[]) it.next();
String firstName = (String) myResult[0];
String lastName = (String) myResult[1];
System.out.println( "Found " + firstName + " " + lastName );
}
You can even create objects like that. If you have a class Name with a two-parameter constructor for first name and last name, you can reformulate your query to get a list of Name objects rather than Object[]:
Code:
Query query = session.createQuery( "select new Name(firstName, lastName) from Person" )