As a workaround why dont you do the retrieve in a microflow and then call that microflow from java. Its much simpler to write the XPath that way and you will also be alerted when some Entities or attribute names change. I find this much safer than doing the retrieve in java. IOP you should use java only for the things that you can not do in mendix.
-Andrej
Hi Purva,
There is a forum post that already answer your question, please can you have a look into this forum post.
Hope this helps!
Hi Purva,
Have a look at the documentation in the Core for createXPathQuery, it gives a good example which I’ll repeat here.
public getObjectsWithValue(IContext context, ICore core, int value) {
List<IMendixObject> results = core.createXPathQuery("//Entity[attribute=$value]")
.setVariable("value", 1)
.setAmount(500)
.setOffset(50)
.setDepth(1)
.execute(context);
return results;
}
You just need to adjust this to match your query.
Hope this helps
Hi
You can use OQL Queries inside JavaAction.
this.OqlQuery = "select * from Module.EnityName where where name='@name@'";
this.OqlQuery = this.OqlQuery.replace("@name@", this.name);
IDataTable resultDT = Core.retrieveOQLDataTable(this.context, this.OqlQuery);
List<? extends IDataRow> rows = resultDT.getRows();
if(rows.size() != 0) {
for (IDataRow row: rows) {
String name = row.getValue(this.context, "name");
}
}