cayenneContext.deleteObjects(ObjectSelect.query(MyTable.class).select(cayenneContext));
is not very efficient for many objects.
Is there anything elegant like ObjectDelete.delete(MyTable.class)
that I failed to discover?
SQLExec.query("delete from MY_TABLE").execute(cayenneContext);
is fine, if no better way to do it. But I'd need to know the table name for this (I have another question for that).
Selecting objects first to delete them is the ORM way to keep the in-memory object graph consistent (and to process delete rules, callbacks, etc.). But yeah, it is not very efficient for large batches.
SQLExec
would be the recommended way to do it directly in the DB. And I answered your other question about the table name.