Retrieving a list of objects with null in the properties after applying resultTransformer

In a criteria query I am getting a list of results in a right way.

As I dont want to all the fields from the entities projection is introduced to specify these fields. Ok, with projection is working fine but, instead of a List of entity is getting a list of object.

As I read, I need to apply setResultTransformer(ClassName.class). When resultTransformer is applied, a list of className are retrieved but all the atributes of the object are NULL. I have tried different parameters to the resultTransformer and always getting a list of object with null in all attributes.


       new AliasToBeanResultTransformer(TramiteTrafico.class));

If not resultTransformer is applied getting values are right. Any idea why?

Thanks all!!


You need to have the property name of the class match the alias used in the projection list.

Something like list

class CatVO {
  String getCatName()  { ..}
  void setCatName(String catName) {..}
  String getKitName()  { ..}
  void setKitName(String kitName) {..}

List results = session.createCriteria(Domestic.class, "cat")
    .createAlias("kittens", "kit")
    .setProjection( Projections.projectionList()
        .add(""), "catName" )
        .add(""), "kitName" )
       new AliasToBeanResultTransformer(CatVO.class))

Need Your Help

java.lang.IllegalArgumentException: Named query not found: LOAD DATA INFILE

mysql spring jpa load-data-infile

I am desperately hoping that someone could help shine some light on this for me as I have been struggling to find the solution for several hours and not getting anywhere.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.