|
Page Created :
CAYDOC :
Custom BatchQueryBuilder Factory
Custom BatchQueryBuilder Factory has been created by Andrey Razumosky (Jun 03, 2009). Content: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 UPDATE ARTIST SET DELETED = true WHERE ARTIST_ID = 1987
instead of DELETE FROM ARTIST WHERE ARTIST_ID = 1987 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: DataDomain domain = Configuration.getSharedConfiguration().getDomain();
domain.setQueryBuilderFactory(new SoftDeleteQueryBuilderFactory());
org.apache.cayenne.access.jdbc.SoftDeleteQueryBuilderFactory is a custom factory built into Cayenne which replaces DELETE queries with UPDATEs as described above.
|
Unsubscribe or edit your notifications preferences
