Core.createXPathQuery.setVariable(String, Collection) usage

0
Hi community,   I'm trying to create a XPath query with "in" operator, but this operator seems not to exist in Mendix, thanks to the documentation. I have 2 entites Person and Country (with a Person -> Country association defined); I would like to retrieve all Percons where the Country is "France", "Germany" or "Switzerland". I can use a "or" operator, but the list of countries can be very long ; I would like to use something like "in" operator. I saw in the Java API that "Core.createXPathQuery" class has a "setVariable(String, Collection)", which might be useful here. Unfortunately, there is no example in the doc neither in the javadoc, and I couldn't find a way to use it by testing. I have the following error : Caused by: scala.MatchError: Vector(ID) (of class scala.collection.immutable.Vector1)    at com.mendix.datastorage.modelresolver.impl.PathParser$.parseEntityRemainder(IdentifierPath.scala:146)    at com.mendix.datastorage.modelresolver.impl.PathParser$.parseEntityPath(IdentifierPath.scala:143)   Has anyone been able to use this method, or to use a "in" operator in their xpath queries ?   Thanks
asked
1 answers
0

I don't think this is possible with xpath in Mendix, you could try to perform the query in OQL this allows for the IN keyword and could allow subselects.

Another option could be to create a list of countries, loop over the list and retrieve the persons per iteration, add the retrieved person records to a list and then you'll have the complete list at the end of the loop.

answered