It's not always a path I recommend, but if you really need specific functionality to avoid a major performance hit, you can always issue native SQL through the Hibernate Session.
Code:
public static void main(String args[]) {
String sql = "SELECT * FROM USER";
Session session = HibernateUtil.beginTransaction();
SQLQuery query = session.createSQLQuery(sql);
List users = query.list();
for (int i = 0; i < users.size(); i++) {
Object[] o = (Object[]) users.get(i);
System.out.print(((Integer) o[0])); //id
System.out.print(((String) o[1])); //email
System.out.print(((String) o[2])); //name
System.out.println(((String) o[3]));//pass
}
}
This code snippet was taken from the following Hiberante3 tutorial:
http://jpa.ezhibernate.com/Javacode/learn.jsp?tutorial=08masteringhqlandnamedqueries
Of course, you can also do custom HQL as well. It's just a matter of weighing the pros and cons.