- Create a new Transformer class
- attach it to an Query or Critiera
- The Query will delivery a fully filled entity
- The Criteria not
- Tested also with Criteria.ALIAS_TO_ENTITY_MAP with the same results
Example-Code:
List objects = getSession().createCriteria(MyEntity.class)
.setResultTransformer(new MyTransformer())
.list();
List objects = getSession().createQuery("from MyEntity"))
.setResultTransformer(new MyTransformer())
.list();
public class MyTransformer implements ResultTransformer {
public Object transformTuple(Object[] rowData, String[] aliasNames) {
// only id is populated in rowData[0] when executed via criteria
}
public List transformList(List list) {
return list;
}
}
Source: http://stackoverflow.com/questions/9913691/3-6-8-criteria-resulttransformer-is-not-populating-tuple-data
|