Cayenne allows plugging user-defined behavior to the process of performing commit actions in ObjectContext. Imagine situation when you need to perform UPDATE queries to mark records in database as deleted, instead of using common DELETE queries, e.g. something like
In such cases you need to intercept Cayenne's process of generating SQL queries. This can be obtained by providing custom org.apache.cayenne.access.jdbc.BatchQueryBuilderFactory to a DataDomain, for example:
org.apache.cayenne.access.jdbc.SoftDeleteQueryBuilderFactory is a custom factory built into Cayenne which replaces DELETE queries with UPDATEs as described above.
You can plug in your own factories. BatchQueryBuilderFactory interface is very simple and contains methods for creating query builders for objects that were inserted, updated or deleted:
Note that BatchQueryBuilder factory only affects queries being created during commit for NEW, MODIFIED or DELETED objects in ObjectContext. It has no effect on database modifications that are made with, say, EJBQLQuery or SQLTemplate.