I would like to "group by" my query results. Unfortunately, I always got a ClassCastExcpetion (I tried category with int and String types, same problem)
Hibernate version: 3.1.3
Mapping documents:
Code:
<class name="Friend">
<composite-id>
<key-property name="member" column="Member_idMember" />
<key-property name="friend" column="Member_idMemberFriend" />
</composite-id>
<property name="category" />
</class>
Code between sessionFactory.openSession() and session.close():Code:
Transaction t = session.beginTransaction();
Criteria criteres = session.createCriteria(Friend.class);
criteres.add(Restrictions.eq("member",member));
[b]criteres.setProjection(Projections.groupProperty("category"));[/b]
List recherche = criteres.list();
for(int i=0;i<recherche.size();i++){
Friend friend = (Friend) recherche.get(i);
friends.add(friend);
}
t.commit();
Full stack trace of any exception that occurs:
java.lang.ClassCastException: java.lang.String
Name and version of the database you are using:
MySQL 4.1