public class EasyConstructorResultTransformer
extends org.hibernate.transform.AliasToBeanConstructorResultTransformer
The purpose is simple : provide a simple way to use an AliasToBeanConstructorResultTransformer.
It is useful when you just want to use a tuple as parameters of a constructor. For HQL queries
it's cheaper than using the AliasToBeanResultTransformer because one don't have to look up
for every setters.
The constructor that will be used is the first one found, so you'd better design your DTO to have exactly one constructor if you don't like surprises.
Some will argue that HQL natively support this (using the "select new org.MyPojo(...)" idiom). However
it doesn't always hold here because we run in an OSGI environment, which leads sometimes to classloading
issues. The most common problematic case is when a "select new" is used with a parameter list :
in this case the Hibernate engine has to expand the "in (:paramlist)" the hql in a new query then parse it again
using the classloader of the thread instead of the one we want (the one of the session factory).
The dev team promised it will be solved by Hibernate 5 (see ReflectHelper and ClassLoaderHelper).
| Constructor and Description |
|---|
EasyConstructorResultTransformer(Class<?> clazz) |
public EasyConstructorResultTransformer(Class<?> clazz)
Copyright © 2010–2017 Henix, henix.fr. All rights reserved.