Using MANY-TO-MANY associations in JPQL :ds$ parameters

Hi!
I have two entities A and B with many-to-many assoc. A screen uses two lookup fields. The first one offers to select any A entity, while the second should offer only that B, which have relation to selected A. A nested datasourse works well, but I need to use extra where conditions (like current B status etc). I suppose something like that should work, but it doesn’t:


select e from muz$Teacher e where  :ds$subjectsDs MEMBER OF e.subjects

because agrument is UUID while mapping uses Entity.


QueryException: 
Exception Description: The class of the argument for the object comparison is incorrect. 
Expression: [null] 
Mapping: [org.eclipse.persistence.mappings.ManyToManyMapping[subjects]] 
Argument: [7a8e4f1c-a460-1bc7-155e-674022b34e1d]

What is the best way to do this?

Hi,

You are right, the platform makes some implicit conversions of query parameters, and you cannot bypass it when issuing queries from the client side. Only the Query interface available on middleware has special variants of setParameter() methods to avoid the conversion.

Nevertheless, you should be able to work around the problem if you rewrite your query, for example:


select b from sample$B b join b.collectionOfA a
where a.id = :ds$aDs
2 Likes

Thanks a lot!