If i run the following query:
... AND :user MEMBER OF c.owners AND ...
it works fine, but if I add the following condition to it like
...AND ( :user MEMBER OF c.owners
OR ( :user MEMBER OF c.department.members AND c.confidential = false )
) AND ...
It doesn't give back the result i want (like the previous query). Any idea why?
EDIT
Here are the relevant part of the generated query (the whole query is the same but these parts)
With this I get back the records I want
and (
? in (
select
owners1_.owner_id
from
contract_owner owners1_
where
contract0_.id=owners1_.contract_id
)
)
With this i din't get is back
and (
? in (
select
owners1_.owner_id
from
contract_owner owners1_
where
contract0_.id=owners1_.contract_id
)
or (
? in (
select
sysuser3_.sysuser_id
from
department_sysuser sysuser3_
where
department2_.id=sysuser3_.department_id
)
)
and contract0_.confidential=0
)
EDIT2:
In the first snippet i get back 1 record (dev data only, in prod it would be more), and in the second part i want to get back the same record, but it doesn't give it back.
The user is the owner of the contract.