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
|