-->
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: Problem with Assigning createSQLQuery() Result to a class
PostPosted: Tue Sep 14, 2010 5:21 am 
Newbie

Joined: Tue Sep 14, 2010 3:34 am
Posts: 1
We have a well defined "actionsport" class that represent the following query result. And the query is

SELECT * FROM (
SELECT a.id,
s.name,
FROM ACTION as a,
SPORT as s
) WHERE rownum <=300;

I am stucked when try to cast the query result to the actionsport class.
I have used the following methods:
1.
Code:
Query q = getSession.createSQLQuery().addEntity(actionsport.Class)

And this does not work.
2. we modified the query to be
SELECT {acs.*} FROM .....
and
Code:
Query q = getSession.createSQLQuery().addEntity("acs",actionsport.Class)

And this does not work either.
3. we modified the query to be
SELECT {acs.*} FROM (
SELECT a.id as {acs.id},
s.name as {acs.name},
FROM ACTION as a,
SPORT as s
) WHERE rownum <=300;
And this does not work either.
4. we also changed the code
[code] Query q = getSession.createSQLQuery().addScalar("id", Hibernate.LONG).addScalar("name", Hibernate.CHARACTER)[\code]

There may be some typo errors but illustrate the main idea.
So my question is: is there a feasible way to make the result of a similar query (The one I used here) mapped to the java class object?
Any suggestion would be greatly appreciated.


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.