-->
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.  [ 3 posts ] 
Author Message
 Post subject: Criteria ProjectionList
PostPosted: Wed Sep 21, 2005 6:33 am 
Newbie

Joined: Wed Sep 21, 2005 5:51 am
Posts: 3
Hi there,

i'm rather new to hibernate and i guess my problem is somewhre explained, but i really can't find information on that.

Is there anything like a criteria API FAQ or tutorial or a more detailed documentation then part 16 of hibernate docs?

My problem is that i don't know what's inside the list that is returned by the method below that uses a ProjectionList.

In this case i have two temporary properties like "rank" and "sum(amount)", that are not in my stat class, so i guess the contents of the list will be kind of "Projection" or "ProjectionList", that provides getters for the Projections.

Would be great if someone can help me out...

Here's my code (hibernate version 3.0):

Code:
public List getTotalStats (Date d) {

   Session session = HibernateUtil.currentSession();             
   Criteria stat = session.createCriteria(Stat.class);
             
   stat.add(Expression.eq("date", d));
   stat.setProjection(Projections.projectionList()
         .add(Projections.groupProperty("site"))            
         .add(Projections.property("site"))
                        .add(Projections.rowCount(), "rank" )   
                        .add(Projections.sum("amount"), "totalListings"));                     
   return stat.list();      
}

// that's where i'm stuck

List list = getTotalStats(mydate);
for (WhatObjectIsIt w : list) {
  // get my data
}



Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 28, 2005 5:54 am 
Newbie

Joined: Wed Sep 28, 2005 4:07 am
Posts: 11
Take a look at the javadoc of:

org.hibernate.transform.AliasToBeanResultTransformer

_________________
Lars Fiedler


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 28, 2005 8:30 am 
Newbie

Joined: Wed Sep 21, 2005 5:51 am
Posts: 3
That's it! Thanks.


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

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.