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

Append a zero to value if necessary in SQL statement DB2

sql db2

I have a complex SQL statement that I need to match up two table based on a join. The the intial part of the complex query has a location number that is stored in a table as a Smallint and the sec...

ImportError: No module named dtmilano

android eclipse pydev jython androidviewclient

Hi I am new to python development. I am trying to execute the code given at but when ever i am trying to execute the cod...

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.