-->
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.  [ 5 posts ] 
Author Message
 Post subject: Criteria Query
PostPosted: Tue Sep 13, 2005 12:05 pm 
Regular
Regular

Joined: Thu Sep 23, 2004 11:53 am
Posts: 83
Hibernate version:
3.1
Mapping documents:
NA
Code between sessionFactory.openSession() and session.close():
NA
Full stack trace of any exception that occurs:
NA
Name and version of the database you are using:
NA
The generated SQL (show_sql=true):
NA
Debug level Hibernate log excerpt:
NA

Can I return a single column using Criteria Queries? Example, If I have entity
Cat {
Name
Color
}

and I only want to return Name not the entire entity.


Top
 Profile  
 
 Post subject: Re: Criteria Query
PostPosted: Tue Sep 13, 2005 1:29 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
noone wrote:
Hibernate version:
3.1

Can I return a single column using Criteria Queries? Example, If I have entity
Cat {
Name
Color
}

and I only want to return Name not the entire entity.


Not using Criteria queries. But you can using HQL easy enough.

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 13, 2005 1:30 pm 
Regular
Regular

Joined: Mon Aug 29, 2005 9:46 am
Posts: 102
As far as I know... No, it can't happen. But you could use "createQuery" instead and select only the column. Or you could get the object and ignore the other columns, using only the one you want.


Top
 Profile  
 
 Post subject: projection
PostPosted: Thu Sep 15, 2005 9:28 am 
Newbie

Joined: Tue Jun 14, 2005 12:44 pm
Posts: 19
How about trying to set a projection on the column (property) name? You will receive only the requested column.

Code:
criteria.setProjection(Projections.property("Id"));


Good luck.


Top
 Profile  
 
 Post subject: Re: projection
PostPosted: Tue Aug 28, 2012 1:41 am 
Newbie

Joined: Tue Aug 28, 2012 1:35 am
Posts: 1
eyalg wrote:
How about trying to set a projection on the column (property) name? You will receive only the requested column.

Code:
criteria.setProjection(Projections.property("Id"));


Good luck.



Thanks buddy. Projection works! :)


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