Say I have a class Entity with a field myCollection that is a List or other type of Collection. When I load instances of Entity via Hibernate, the myCollection field is populated correctly. However, if I do a Criteria query and I have a property projection for the myCollection field, the data returned (List<Object[]>) always contains a null corresponding to myCollection in each row, e.g. ([1, null], [2, null], ...). Does Hibernate support doing this type of projection on a field that is a Collection?
Code:
class Entity {
public Long id;
public List<String> myCollection;
}
Criteria cr = getCurrentSession().createCriteria(Entity.class)
.setProjection(Projections.projectionList()
.add(Property.forName("id"))
.add(Property.forName("myCollection"))
);