-->
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: Different Result from createQuery and createSQLQuery
PostPosted: Wed Jul 18, 2007 3:28 am 
Newbie

Joined: Fri Dec 15, 2006 12:26 pm
Posts: 8
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


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.