This is a very old question, but it is a bit vexing as to why there isn't something like this in the transformers already.
Running the query with the transformer:
Query sqlQuery = session.createSQLQuery(sqlStatement); sqlQuery.setResultTransformer(AliasToEntityLinkedMapResultTransformer.INSTANCE); List results = query.list();
For the transformer, I extended BasicTransformerAdapter as opposed to AliasToEntityMapResultTransformer.
import org.hibernate.transform.BasicTransformerAdapter public class AliasToEntityLinkedMapResultTransformer extends BasicTransformerAdapter implements Serializable { public static final AliasToEntityLinkedMapResultTransformer INSTANCE = new AliasToEntityLinkedMapResultTransformer(); private AliasToEntityLinkedMapResultTransformer() { } public Object transformTuple(Object[] tuple, String[] aliases) { Map result = new LinkedHashMap(tuple.length) for (int i = 0; i < tuple.length; i++) { String alias = aliases[i] if (alias != null) { result.put(alias, tuple[i]) } } return result; } private Object readResolve() { return INSTANCE } public boolean equals(Object other) { return other != null && AliasToEntityLinkedMapResultTransformer.class.isInstance(other) } public int hashCode() { return getClass().getName().hashCode() } }
Nothing revolutionary or straightforward, but there it is.