-->
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.  [ 4 posts ] 
Author Message
 Post subject: HIB 3.1.3 Named Parameter allowed in Select Clause?
PostPosted: Thu Feb 08, 2007 11:54 am 
Newbie

Joined: Mon May 08, 2006 6:02 pm
Posts: 3
Location: Michigan
I am working on an insert into...select statement, and I ran into an issue with using named parameters in the select clause (see HQL below). My thought was that I could use the parameters instead of actual values to reduce the number of prepared statements generated. Is this supported in HQL? If so, what am I doing wrong in my query?

insert into DataReqSetDetail
(dataReqSet, moduleDataReqAssoc, orderNumber, createdBy, modifiedBy)
select drs, mdra, :order, :createdBy, :modifiedBy
from DataReqSet as drs, ModuleDataReqAssoc as mdra
where drs.id = :dataReqSetId
and mdra.id = :moduleDataReqAssocId

The query works if I provide values for :order, :createdBy and :modifiedBy parameters as follows:

insert into DataReqSetDetail
(dataReqSet, moduleDataReqAssoc, orderNumber, createdBy, modifiedBy)
select drs, mdra, 1, 'username', 'username'
from DataReqSet as drs, ModuleDataReqAssoc as mdra
where drs.id = :dataReqSetId
and mdra.id = :moduleDataReqAssocId


Thanks in advance,
Scott


Top
 Profile  
 
 Post subject: giving paramatere values
PostPosted: Fri Feb 09, 2007 4:25 am 
Beginner
Beginner

Joined: Wed Nov 15, 2006 4:25 am
Posts: 21
Hi

You are selecting from the table but i think you are nowhere setting the data of :nnnnn,:nnnnnn,:nnnnnn

In the second query you are giving the values but in the first query where are you giving the values ? you are only retrieving but not setting the values for parameters.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 09, 2007 12:50 pm 
Newbie

Joined: Mon May 08, 2006 6:02 pm
Posts: 3
Location: Michigan
Shantha,

Thank you for your reply. In the java code related to the query, I provided values for each of the named parameters.

Hibernate was unable to parse into SQL and threw a query exception with the named parameters in the select clause.

Scott


Top
 Profile  
 
 Post subject: problem in parsing sql query in hibernate
PostPosted: Sat Feb 10, 2007 12:50 am 
Beginner
Beginner

Joined: Wed Nov 15, 2006 4:25 am
Posts: 21
Hi shammer64


Can u please post the query so that i can have a look at it.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.