I have a native SQL query that returns several computed results (such as sums and averages from several tables) and I want to load these results into a custom object that contains all the necessary fields. I'm aware that Hibernate provides the
Query query = this.sessionFactory.getCurrentSession().createSQLQuery(queryString.toString());
return (List<CustomObject>)query.list(); //doesn't work, obviously
Look at result transformers. They are designed to do exactly what you are looking for and work for both HQL and SQL.