Hibernate version: 2.1.6
I have a Hibernate persisted object, Recipe, in a table "recipe". I need to utilize a native SQL statement like the following:
Code:
select substring(lower(name) from 1 for ?) as section, count(*) as cnt from recipe group by section
but obviously this is not intended to return recipe objects... as a Recipe object does not have either "section" or "cnt" properties.
My question is, in general what is the appropriate way to accomplish this type of arbitrary native SQL in Hibernate? There are some cases where I want to execute arbitrary queries that return result sets that don't map to Hibernate-persisted object properties.