Hi,
I have a mytable whose columns in hbm are defined as below
<property
name="Name"
column="name" />
<property
name="Age"
column="age" />
Table Data
name age
John 10
Peter 20
I want run simple query as
select sum(age), count(name) from mytable
the output at database end is 30, 2
Problem is when i try to execute same query using createSQLQuery of hibernate the result is 30, 30 which is same as the aggregation of first function.
Now when i tried using createQuery the output is 30,2 but the constraint for me is, i have to give exactly the same name of column as i have given in hbm ie:
select sum(Age), count(Name) from mytable
The input of query for me is from the user who knows database column names not the hbm property names.
Kindly help me out if there is some way to tackle the situation.
thanks
|