-->
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: Setting Parameters in subselect (common table expression)
PostPosted: Thu Apr 27, 2006 1:49 pm 
Newbie

Joined: Fri Mar 03, 2006 2:11 pm
Posts: 16
Hibernate version:
3.1.2
Name and version of the database you are using:
DB2 8.x
***************
I have legacy SQL query which has 'common table expression' like:

SELECT QRY1.COL1, QRY2.COL2 FROM ( SELECT TAB1.COL1 FROM TAB1 WHERE TAB1.COL2=?) AS QRY1 LEFT OUTER JOIN (SELECT TAB2.COL2 FROM TAB2) AS QRY2 ON QRY1.COL1=QRY2.COL2)

As Hibernate does not support coomon table expressions (that is my understanding) I am trying to add this type of expressions, in this case common table expression 'SELECT TAB1.COL1 FROM TAB1 WHERE TAB1.COL2=?', as part of 'subselect' feature. When I use this way it is working fine if there are no parameters to be set. In case I have some user input to be passed on to subselect statements for positional params using 'setparameter' method, how do I do that? When I try to use it is not working. Are there any other ways to address 'common table expressions' with paramaeters to be set?

With this client we are exploring the possibilites to use Hibernate in place of JDBC. They have lot of legacy SQL code which has heavy usage of 'common table expressions' with paramaters to be set from user input.

Any help is appreciated to find alternatives if subselect is not the option.

Thank you


Top
 Profile  
 
 Post subject: Re: Setting Parameters in subselect (common table expression
PostPosted: Thu Apr 27, 2006 2:01 pm 
Newbie

Joined: Fri Mar 03, 2006 2:11 pm
Posts: 16
nandyala wrote:
Hibernate version:
3.1.2
Name and version of the database you are using:
DB2 8.x
***************
I have legacy SQL query which has 'common table expression' like:

SELECT QRY1.COL1, QRY2.COL2 FROM ( SELECT TAB1.COL1 FROM TAB1 WHERE TAB1.COL2=?) AS QRY1 LEFT OUTER JOIN (SELECT TAB2.COL2 FROM TAB2) AS QRY2 ON QRY1.COL1=QRY2.COL2)

As Hibernate does not support coomon table expressions (that is my understanding) I am trying to add this type of expressions, in this case common table expression 'SELECT TAB1.COL1 FROM TAB1 WHERE TAB1.COL2=?', as part of 'subselect' feature. When I use this way it is working fine if there are no parameters to be set. In case I have some user input to be passed on to subselect statements for positional params using 'setparameter' method, how do I do that? When I try to use it is not working. Are there any other ways to address 'common table expressions' with paramaeters to be set?

With this client we are exploring the possibilites to use Hibernate in place of JDBC. They have lot of legacy SQL code which has heavy usage of 'common table expressions' with paramaters to be set from user input.

Any help is appreciated to find alternatives if subselect is not the option.

Thank you


Please note that I have tried with NativeSQL and have no issues. I was trying to understand and explore if there are any other alternatives to address such issues.

Thank you


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 27, 2006 2:13 pm 
Expert
Expert

Joined: Tue Apr 25, 2006 12:04 pm
Posts: 260
Subselects can be enabled using Criteria based queries. Check out in the reference documentation Chapter 15. Also within this last 2 days I have tried to put some questions on Criteria and got some replies - so please refer to them.


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.