Table of Contents
DODS gives you the option to choose how you want to modify rows of table in database. Obvious one is to use instances of generated DO classes:
SomeDOClass sgDO = SomeDOClass.createExisting(oid); sgDO.delete();
Other option is QueryBuilder, which may be used to build not only select queries, but update or delete statements, as in:
QueryBuilder qb = getQueryBuilderForClass("SomeDOClass"); qb.setDeleteQuery(); qb.addWhereClause("oid", Integer.parseInt(enumoid), QueryBuilder.EQUAL); qb.executeUpdate();
There could be a situation where you may want to touch many rows at once. First approach must be encompassed by loop which would iterate value of oid, thus producing many separate SQL statements. This isn't efficient at all, and it gets slower as number of rows raises.
Second approach, using QueryBuilder produces one SQL statement, and executes much faster. But:
Cache implementation in DODS includes caching DataStructs and queries for table globally, and caching DO objects in transaction. Both caches are implemented in generated classes only, so using QueryBuilder won't touch caches.
Direct use of QueryBuilder is NOT recommended, since it doesn't affect any of the caches, and your application may work erroneously.