-->
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: Getting value for some columns
PostPosted: Fri Oct 27, 2006 8:26 am 
Newbie

Joined: Fri Oct 27, 2006 7:51 am
Posts: 2
Hello

How can i get values for some columns when i have mapped all columns from my table. Something like "select t.id, t.name from table t" (table has five another columns).

I know that it can be doing like this:
org.hibernate.Session session;
.....
session.createQuery("select new Table(t.id,t.name) from table t");

but i want to use "session.createCriteria()".
I think that i should implement my own "ResultTransformer" and use "dbSession.createCriter().setResultTransformer()". Is another way to do this ?


Best regards.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 27, 2006 8:33 am 
Senior
Senior

Joined: Wed Aug 17, 2005 12:56 pm
Posts: 136
Location: Erie, PA (USA)
Use Criteria.setProjection(Projection projection) where a projection is obtained from Projections class. You will probably want to use setResultTransformer(ResultTransformer resultTransformer) in order to place the results in bean rather than an Object[].

Curtis ...

_________________
---- Don't forget to rate! ----


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 27, 2006 8:56 am 
Newbie

Joined: Fri Oct 27, 2006 7:51 am
Posts: 2
Thank you very much.

This is exactly what i want.

Best regards.


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.