-->
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: criteria queries
PostPosted: Wed Dec 22, 2010 9:15 am 
Newbie

Joined: Tue Dec 14, 2010 7:48 am
Posts: 10
is there any way to get a single property in class, what we are giving in (here Organization.class)


List organizationList = session.createCriteria(Organization.class)
.add(Restrictions.eq("town","pune"))
.add(Restrictions.eq("statusCode","A"))
.list();


if i want only one property from that class...............


Top
 Profile  
 
 Post subject: Re: criteria queries
PostPosted: Wed Dec 22, 2010 1:05 pm 
Regular
Regular

Joined: Wed Feb 15, 2006 9:09 pm
Posts: 76
Use static methods in the org.hibernate.criterion.Projections class, and org.hibernate.Criteria.setProjection():

List organizationList = session.createCriteria(Organization.class)
.setProjection( Projections.property( "propertyName" ) )
.add(Restrictions.eq("town","pune"))
.add(Restrictions.eq("statusCode","A"))
.list();


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.