0

I am using Hibernate criteria and projection to get distinct values as shown below:

Criteria criteria = this.getSession().createCriteria(CmError.class); ProjectionList projList = Projections.projectionList(); projList.add(Projections.property("router")); projList.add(Projections.property("slot")); criteria.setProjection(Projections.distinct(projList)); 

I am using result Transformer with Projection to get list of distinct values

List<CmError> cm = criteria.setResultTransformer(Transformers.aliasToBean(CmError.class)).list(); 

What i am seeing is that all the field values for the list is null while the size of list is correct, meaning number of records i am expecting to return from same distinct SQL query is same as size of the CmError list but data inside list is not populating and returning null when I iterate over the list.

Not sure what i am missing.

1 Answer 1

3

Try to change it to:

projList.add(Projections.property("router"), "router"); projList.add(Projections.property("slot"), "slot"); 
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Alex for the fix.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.