Hibernate partially populated object with projections
===

My question is same exact issue like this [SO question][1]. 

Assume we have entity like


    public class Employee {
        Long getId();
        String getName();
        Address getAddress();  
    }

With the help of createCriteria and Projections we are trying to get id,name from users and city from address table. 

The issue we are having is, city is not being set to address object city property.

Here is the code we tried:

     Criteria cr = session.createCriteria(Employee.class)
                        .setProjection(Projections.projectionList()
                        .add(Projections.property("id"), "id")
                        .add(Projections.property("Name"), "Name")
                        .add(Projections.property("address.city"), "address.city"))
                        .addOrder(Order.asc("address.city"))
                        .createAlias("address", "address")
                        .setResultTransformer(Transformers.aliasToBean(Employee.class));

Based on `JBNizet` comment on above question I understood that partially objects are bad idea, but If I am mandated to do that how can I achieve it? Any input would be appreciated.


  [1]: http://stackoverflow.com/questions/7175399/hibernate-result-transformer?rq=1