The state field path cannot be resolved to a collection type

I have 2 entities (Entity1 & Entity2) that have assosiation attributes “many-to-many” to another entity (Entity3)
Then I tried to use the attributes in jpql query:

select e1 from app$Entity1 e1 where (select COUNT(e2) from app$Entity2 e2 where e2.id = :custom$entityId and e2.entity3 member of e1.entity3) > 0

but got the error:
The state field path ‘e2.entity3’ cannot be resolved to a collection type.

What’s wrong?

Hi Evgeny,

If Entity 2 and Entity 3 have many-to-many association, e2.entity3 member of e1.entity3 is a nonsense, since a collection here cannot be member of another collection. So, try to modify your query.