I need to select distinct id and also need another column
MyClass class1 = new MyClass();
Criteria criteria = new Criteria(MyClass.class);
ProjectionList projList = Projections.projectionList();
projList.add(Projections.property("col1"));
projList.add(Projections.property("col2"));
criteria.setProjection(Projections.distinct(projList));
class1 = criteria.list();
What will be the return type of criteria.list()? If i try to assign it to MyClass.class I get ClassCast Exception. Please assist. How will I get both my columns?
The result of
criteria.list()
must be aList<Object[]>
, so: