Javadoc fixes, make deleteAll() do the right thing if you pass a KeySet into
the WhereClause-only version.
This commit is contained in:
@@ -34,7 +34,7 @@ import com.samskivert.depot.impl.FindAllQuery;
|
|||||||
* Any record type with a primary key has a {@link CacheCategory#RECORD} cache, for storing
|
* Any record type with a primary key has a {@link CacheCategory#RECORD} cache, for storing
|
||||||
* record instances by primary key.
|
* record instances by primary key.
|
||||||
*
|
*
|
||||||
* Record types with primary keys may also have a {@link CacheCategory#KEYSET} cache wherein
|
* Record types with primary keys may also have a {@link CacheCategory#SHORT_KEYSET} cache wherein
|
||||||
* {@link KeySet} instances are stored, identified by query strings. See {@link FindAllQuery}
|
* {@link KeySet} instances are stored, identified by query strings. See {@link FindAllQuery}
|
||||||
* for more on this.
|
* for more on this.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public abstract class DepotRepository
|
|||||||
/** Completely bypass the cache for this query. */
|
/** Completely bypass the cache for this query. */
|
||||||
NONE,
|
NONE,
|
||||||
|
|
||||||
/** Use the {@link #KEYS} strategy if possible, else revert to {@link #NONE}. */
|
/** Use the {@link #SHORT_KEYS} strategy if possible, else revert to {@link #NONE}. */
|
||||||
BEST,
|
BEST,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -114,16 +114,16 @@ public abstract class DepotRepository
|
|||||||
LONG_KEYS,
|
LONG_KEYS,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This cache strategy is direct and explicit, eschewing the dual phases of the
|
* This cache strategy is direct and explicit, eschewing the dual phases of the {@link
|
||||||
* {@link #RECORDS} and {@link #KEYS} approaches. However, before the database is invoked
|
* #RECORDS} and {@link #SHORT_KEYS} approaches. However, before the database is invoked at
|
||||||
* at all, we consult the cache hoping to find the entire result set already stashed away
|
* all, we consult the cache hoping to find the entire result set already stashed away in
|
||||||
* in there, using the entire query as the key. If we failed to find it, we execute the
|
* there, using the entire query as the key. If we failed to find it, we execute the query
|
||||||
* query and update the cache with the result.
|
* and update the cache with the result.
|
||||||
*
|
*
|
||||||
* This strategy has none of the limitations of {@link #KEYS} and can be used with key-less
|
* This strategy has none of the limitations of {@link #SHORT_KEYS} and can be used with
|
||||||
* and @Computed records and arbitrarily complicated queries. Note however that as with
|
* key-less and @Computed records and arbitrarily complicated queries. Note however that as
|
||||||
* {@link #KEYS}, there is no automatic invalidation. It is also potentially very memory
|
* with {@link #SHORT_KEYS}, there is no automatic invalidation. It is also potentially
|
||||||
* intensive.
|
* very memory intensive.
|
||||||
*/
|
*/
|
||||||
CONTENTS
|
CONTENTS
|
||||||
};
|
};
|
||||||
@@ -1037,8 +1037,11 @@ public abstract class DepotRepository
|
|||||||
protected <T extends PersistentRecord> int deleteAll (Class<T> type, final WhereClause where)
|
protected <T extends PersistentRecord> int deleteAll (Class<T> type, final WhereClause where)
|
||||||
throws DatabaseException
|
throws DatabaseException
|
||||||
{
|
{
|
||||||
if (_ctx.getMarshaller(type).hasPrimaryKey()) {
|
if (where instanceof CacheInvalidator) {
|
||||||
// look up the primary keys for all rows matching our where clause and delete using those
|
// our where clause knows how to do its own deletion, yay!
|
||||||
|
return deleteAll(type, where, (CacheInvalidator)where);
|
||||||
|
} else if (_ctx.getMarshaller(type).hasPrimaryKey()) {
|
||||||
|
// look up the primary keys for all matching rows matching and delete using those
|
||||||
KeySet<T> pwhere = KeySet.newKeySet(type, findAllKeys(type, true, where));
|
KeySet<T> pwhere = KeySet.newKeySet(type, findAllKeys(type, true, where));
|
||||||
return deleteAll(type, pwhere, pwhere);
|
return deleteAll(type, pwhere, pwhere);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user