-->
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.  [ 2 posts ] 
Author Message
 Post subject: query objects using criteria
PostPosted: Tue Jul 24, 2007 9:17 am 
Beginner
Beginner

Joined: Wed Oct 04, 2006 8:57 am
Posts: 25
Hibernate version:1.2

I am not sure of the terminology to use here so I will use examples :)

I see that in HQL you can do this:

Code:
select new Family(mother, mate, offspr)
from Eg.DomesticCat as mother


I am using criteria as I have conditions around what err conditions to apply. How can I use this same concept of creating a new object to store the result in?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 25, 2007 3:59 am 
Beginner
Beginner

Joined: Wed Oct 04, 2006 8:57 am
Posts: 25
I found the answer here http://forum.hibernate.org/viewtopic.php?t=963513:


Code:
Projection properties =
Projections.projectionList()
.add(Projections.id())
.add(Property.forName("name"))
.add(Property.forName("shortDesc"));

// Create the selection criteria for the listing.
Criteria selectCriteria =
session.createCriteria(entityName)
.add(criterion)
.setProjection(properties);
.setResultTransformer(new AliasToBeanResultTransformer(Summary.class))


its java but you get the idea..


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.