-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Troubles to make groupPropery work !
PostPosted: Wed Oct 25, 2006 4:46 pm 
Beginner
Beginner

Joined: Tue Sep 19, 2006 1:48 pm
Posts: 20
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.