Strange error when including a sort on retrievexpathquery

1
When I do the following query in java it works fine: List<IMendixObject> attformatter = Core.retrieveXPathQuery(context, query); When I include a sort (sort.put("Order", "ASC")) I get a strange error: List<IMendixObject> attformatter = Core.retrieveXPathQuery(context, query, -1, -1, sort); The error is: Caused by: com.mendix.core.CoreRuntimeException: 'rsonsAndOrganizations.AttributeFormatter' is not a valid entity at hC.d(SourceFile:1557) The Pe from PersonsAndOrganizations are missing. The offset and amount (the -1's) are irrelevant. What can cause this error? UPDATE: Version with sort that results in the error: HashMap<String, String> sort = new HashMap<String, String>(); sort.put(personsandorganizations.proxies.AttributeFormatter.MemberNames.Order.toString(), "ASC"); MemberNames attr = AttributeFormatter.MemberNames.AttributeFormatter_Formatter; String query = AttributeFormatter.entityName + "[" + attr + "='" + FormatterParameter1.getGUID() + "']"; List<IMendixObject> attformatter = Core.retrieveXPathQuery(context, query, -1, -1, sort); Version without sort that works fine (of course sort is not necessary here): HashMap<String, String> sort = new HashMap<String, String>(); sort.put(personsandorganizations.proxies.AttributeFormatter.MemberNames.Order.toString(), "ASC"); MemberNames attr = AttributeFormatter.MemberNames.AttributeFormatter_Formatter; String query = AttributeFormatter.entityName + "[" + attr + "='" + FormatterParameter1.getGUID() + "']"; List<IMendixObject> attformatter = Core.retrieveXPathQuery(context, query);
asked
3 answers
5

When doing an xpath query, you should start with 2 forward slashes (//). In some cases the runtime can deal with these slashes missing, but for doing a sort, the runtime needs to determine the entity type up front. That's why your 'Pe' is going missing, the slashes are removed rather agressively, but even in your first case it's better to just add the slashes.

answered
0

I suggest you to take other parameters than -1, -1 for amount and offset. For example 1000, 0

answered
0

Are you sure you don't hava a typo in you sorting paths? It looks like it is trying to find 'rsonsAndOrganizations.AttributeFormatter' and cannot find it. I Don't know your model, but it looks like it should be 'PersonsAndOrganizations.AttributeFormatter'

answered