hi dilembus , i think u didnt understood my question. The solution which you provided is to convert the resultset to any persistent class. But my requirement doesnt have the persistent class itself.
Imagine you have a StudentDTO class:
Code:
public class StudentDTO {
private String studentName;
private String courseDescription;
public StudentDTO() { }
...
}
Then you can make the Criteria return non-entity classes instead of scalars or entities by applying a ResultTransformer:
Code:
List resultWithAliasedBean = s.createCriteria(Enrolment.class)
.createAlias("student", "st").createAlias("course", "co")
.setProjection( Projections.projectionList()
.add( Projections.property("st.name"), "studentName" )
.add( Projections.property("co.description"), "courseDescription" )
)
.setResultTransformer( Transformers.aliasToBean(StudentDTO.class) )
.list();
StudentDTO dto = (StudentDTO)resultWithAliasedBean.get(0);
This is how we will use resultsettransformer right??
But how does it helps to solve my question????
I am still searching for a solution. Will let you know once i get it.
Also i am looking for an API which will give me the SQL query back to me.
Like after setting all the filters and where class in the Query object, when we do query.list() ... that time it converts the query based on the dialect and it fires the query. I am trying to find a way to get that firing query. Just help me out if you one.
Anyway thanks for your quick reply.