コード例 #1
0
 /**
  * Expires a type with specific identities from cache.
  *
  * <p>Objects expired from the cache will be read from persistent storage, as opposed to being
  * read from the performance cache, during subsequent load/query operations.
  *
  * <p>When objects are expired from the cache individually, by identity, objects contained within
  * a "master" object, for example objects maintained in a one-to-many relationship, will
  * automatically be expired from the cache, without the need to explicitly identify them. This
  * does not apply when expiring objects by type. Each type, both container and contained objects
  * need to be specified.
  *
  * <p>
  *
  * @param type The type to expire.
  * @param identity An array of object identifiers to expire.
  */
 public void expireCache(final Class type, final Object[] identity) throws PersistenceException {
   testForOpenDatabase();
   ClassMolder molder = _lockEngine.getClassMolder(type);
   for (int i = 0; i < identity.length; i++) {
     _transactionContext.expireCache(molder, new Identity(identity[i]));
   }
 }
コード例 #2
0
  /**
   * Indicates whether am instance of cls is currently cached.
   *
   * @param cls The class type.
   * @param identity The object identity.
   * @return True if the object is cached.
   * @throws PersistenceException If a problem occured resolving the object's cache membership.
   */
  public boolean isCached(final Class cls, final Object identity) throws PersistenceException {
    if (_transactionContext != null && _transactionContext.isOpen()) {
      return _transactionContext.isCached(
          _lockEngine.getClassMolder(cls), cls, new Identity(identity));
    }

    throw new PersistenceException("isCached() has to be called within an active transaction.");
  }