Hi everybody,
Here is my problem, I am trying to write a query like this :
from MyClass cls where cls in (select cls2.cls from MyOtherClass)
The problem is that MyClass has a multiple column key (key1,key2,key3)
Because there are three elements that identifies my object of class MyClass.
Now the issue:
We are using MSSQL 2005 and the query that has been produced doesn't work. The problem comes from the in clause on the subquery.
I am not sure but it looks like having a subquery with multilpe columns doesn't work. Can someone help me knowing why it doesn't work and why am I doing wrong? Thanks in advance
Here is the HQL query:
Code:
from Invoice inv where (inv.shipments.size=:param1 and inv.key.invoiceNumber in ( select key.Invoice from ItemPosition it))
Here is the generated query:
Code:
select
invoice0_.INVOICENUMBER as INVOICEN1_38_,
invoice0_.deliveryNumber as delivery2_38_,
invoice0_.IDINVOICEPLANT as IDINVOIC3_38_,
from
Invoice invoice0_
where
(
select
count(shipments1_.InvoiceNumber)
from
ShipmentInvoices shipments1_
where
invoice0_.INVOICENUMBER=shipments1_.InvoiceNumber
and invoice0_.deliveryNumber=shipments1_.deliveryNumber
and invoice0_.IDINVOICEPLANT=shipments1_.idInvoicePlant
)=?
and (
(
invoice0_.INVOICENUMBER, invoice0_.deliveryNumber, invoice0_.IDINVOICEPLANT
) in (
select
itempos2_.InvoiceNumber,
itempos2_.deliveryNumber,
itempos2_.idInvoicePlant
from
ItemPosition itempos2_
)
)
)