-->
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.  [ 1 post ] 
Author Message
 Post subject: Criteria API: Entities along-side Additional Expressions
PostPosted: Thu Feb 07, 2008 3:06 am 
Newbie

Joined: Thu Feb 07, 2008 2:58 am
Posts: 1
All,

Is it possible to use the Criteria API to select additional columns in addition to the root entity?

For example -- assume we have a Person entity with Name, Age, etc. We want to construct a query using the Criteria API which will select everyone in the table who is 35 years old while also selecting a few additional columns (or SQL expressions) which aren't mapped as part of the Person entity.

It seems like a ResultTransformer could perhaps be used to work with the result of such a query, but I can't seem to find any way to add the additional columns to the query. Projections sort-of do this, but they don't select the root entity -- and we want to select the root entity along-side the additional expressions.

To give a more practical example: Given an entity, ShoppingMall, which has name, streetAddress, city, state, zip and a geocode, we want to select all the shopping malls in a given city and, in the same query, use the database's spatial capabilities to get the distance from a user specified location to that mall. This would require selecting an extra SQL expression (SDO_DISTANCE() in Oracle, for example) in addition to the columns required for the ShoppingMall entity.


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

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.