Hi !
I use an AliasToBeanResultTransformer and a ProjectionList on most of my search queries for performance and memory reasons: I don't want to to select all fields of root + joined tables.
The problem is that I need to create a Bean with getters/setters for each selected fields.
Here is an example:
Code:
class PersistantClass1 {
private string label;
private PersistantClass2 parent;
//...dozen of other properties...;
//getters/setters
}
class PersistantClass2 {
private String parentLabel;
private int parentOrder;
//...dozen of other properties...;
//getters/setters
}
I want to select label, parentLabel, parentOrder order by parentLabel
Actually I have to use a ProjectionList
Code:
projectionList.add(Projections.property("label"), "label");
projectionList.add(Projections.property("parent.parentLabel"), "parentLabel");
projectionList.add(Projections.property("parent.parentOrder"), "order");
and create a bean:
Code:
class MyBean {
private String label;
private String parentLabel
private int order;
//getters and setters
}
Is there a possibility to reuse my Entity to avoid creating a Bean for each query ?
I would use "." in aliases to tell hibernate how the entity is structured to call the .setter.setter....
like this:
Code:
projectionList.add(Projections.property("label"), "label");
projectionList.add(Projections.property("parent.parentLabel"), "parent.parentLabel");
projectionList.add(Projections.property("parent.parentOrder"), "parent.parentOrder");
actually, hibernates complains "parent.parentLabel property not found" .
If it could perform split(".") to find the setters, it would be great !
Did I miss something ?
Is it already possible to do this (without using HQL...I need criteria because of mutiple dynamic where clauses)
Hibernate version:
3.2.5