No, unfortunately, if you want to delete a MendixObject, you always need to instantiate it. If you'd like to be able to delete by ids or delete by xpath you can request those features at MXDN.
It is possible to use some more complex java code to remove the objects. In my experience this could be faster then retrieving a complete IMendixObject.
This is what the code does: First it retrieves all objects id's with oql, the only thing the xas does is creating an identifier for each object.
Then for each id in the result a new thread is started by the core to remove the id's, because I don't want to have to many open request the code waits after 50 calls untill the core is finished.
You can try if this works for you. But keep in mind that this could be a pretty heavy process for your server and if you have to many async remove calls the server could slow down so much that users will experience some performance problems.
private void removeObjects( ) throws CoreException {
IDataTable table = Core.retrieveOQLDataTable(this.getContext(), "SELECT id FROM moduleName.ObjectType WHERE myObjectStatus = 'targetStatus' ");
if( table.getRowCount() > 0 ) {
List<Future<Boolean>> futureList = new ArrayList<Future<Boolean>>();
List<? extends IDataRow> rows = table.getRows();
for( IDataRow row : rows ) {
IMendixIdentifier id = row.getValue(0);
futureList.add( Core.removeAsync(this.getContext(), id, true) );
if( futureList.size() >= 50 )
proccessFutureList(futureList);
}
proccessFutureList(futureList);
table.close();
}
}
private void proccessFutureList( List<Future<Boolean>> futureList ) throws CoreException {
for( Future<Boolean> f : futureList ) {
try {
f.get();
}
catch (Exception e) {
throw new CoreException(e);
}
}
futureList.clear();
}