-->
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.  [ 3 posts ] 
Author Message
 Post subject: Convert HQL to SQL
PostPosted: Mon Sep 21, 2009 12:56 pm 
Newbie

Joined: Wed Mar 15, 2006 10:56 am
Posts: 8
Location: Ohio USA
Hi all,
I have a HQL which joins 2 tables Table A and Table B. Each have a column say id
I need the results of (A minus B ) something of the following sort
select from A where A.id = B.id and A.id not in (select id from B).

I am using HQL for this.

But the result is coming back to me as an Object[]. Is there a way that I can convert the HQL into a SQL so that I can use sqlQuery.addEntity(theClass);

Regards
Ramesh Kesavanarayanan


Top
 Profile  
 
 Post subject: Re: Convert HQL to SQL
PostPosted: Mon Sep 21, 2009 5:16 pm 
Senior
Senior

Joined: Mon Jul 07, 2008 4:35 pm
Posts: 141
Location: Berlin
Hi kesavramesh,

I guess there is - just write an SQL query that retrieves the same result as the HQL query.

Or what do you mean? Automated conversion from HQL > SQL?

CU
Froestel

_________________
Have you tried turning it off and on again? [Roy]


Top
 Profile  
 
 Post subject: Re: Convert HQL to SQL
PostPosted: Sat Sep 26, 2009 3:52 pm 
Regular
Regular

Joined: Thu Apr 14, 2005 10:39 am
Posts: 115
Quote:
select from A where A.id = B.id and A.id not in (select id from B).


Is always empty! If A.id matches B.id; A.id will be in the B-table. So the second expression is always false if first is true and vice versa.

Otherwise you can get the SQL from the log file with debug level. Or wit the "show sql" property.

Even I can't image what you want to do with "addEnity"?
What's wrong with Object[]?

Greetings Michael


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

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.