Hibernate version: 3.1.3
Name and version of the database you are using: Oracle 10.2.0
If you have an inheritance tree of objects mapped in Hibernate, for example:
Code:
public abstract class BaseClass { }
public class classA extends BaseClass { }
public class classB extends BaseClass { }
When you use criteria to search for all objects of BaseClass, you get as result a list with instances of classA and instances of classB.
But I want to use a projection list in combination with an AliasToBeanResultTransformer. This maps the specified attributes on the attributes of the DTO class specified in the ResultTransformer.
But how can I map the name of the class of the result instance (classA or classB) to the DTO object? I have to know what type it is.
Code:
criteria = session.createCriteria(BaseClass .class);
criteria.setProjection(Projections.projectionList()
.add(Projections.property("oid"), "oid")
.add(Projections.property("year"), "articleYear")
.add(Projections.property("number"), "articleNumber")
.add(Projections.property("description"), "description")
.add(Projections.????????, "className")
);
criteria.setResultTransformer(new AliasToBeanResultTransformer(BaseDTO.class));
Thanks in advance for any help!