Xpath to OQL translation

3
Hi all, For a customer I am building a complex, SAP like, search functionality in Mendix. Since searching should be possible on multiple attributes in multiple associated objects, I am creating an optimized XPath string in Java, and fire that XPath via Core.retrieveXPathQuery to the database to retrieve the correct objects. To optimize the performance of the process I would also like to be able to convert the build up XPath to a valid OQL query. Does anybody know of such a translation already being available somewhere?
asked
3 answers
1

To get these two numbers you would have to do an aggregate query separately from the retrieve.

If you are working in Java anyway this is pretty easy. The core api also has the retrieve xpath aggregate function available.
You would simply have to write one line of code extra and re-use the xpath that you already have, that way you can't make any translation mistakes either.

Just use the code below:

long countResult = Core.retrieveXPathQueryAggregate( "COUNT(" + myXPath + ")" );

The platform will translate that to an SELECT COUNT(*) OQL/SQL query and just give you the qty back

answered
0

Have you tried searching using a List View object - you are able to define multiple attributes from the main or associated objects to search on, in a single search field

answered
0

I can't figure how you could accomplish this without running 2 queries, which can still be done with XPath. For the aggregate query, wrap your Xpath query with the count() function. For the 100 record limit, use the additional parameters offset and limit parameters to Core.retrieveXPathQuery.

answered