Exemplo n.º 1
0
  /**
   * Flushes all value caches contained within entities controlled by this <code>EntityManager
   * </code> instance. This does not actually remove the entities from the instance cache maintained
   * within this class. Rather, it simply dumps all of the field values cached within the entities
   * themselves (with the exception of the primary key value). This should be used in the case of a
   * complex process outside AO control which may have changed values in the database. If it is at
   * all possible to determine precisely which rows have been changed, the {@link
   * #flush(RawEntity...)} method should be used instead.
   */
  public void flushAll() {
    List<Map.Entry<RawEntity<?>, EntityProxy<? extends RawEntity<?>, ?>>> toFlush =
        new LinkedList<Map.Entry<RawEntity<?>, EntityProxy<? extends RawEntity<?>, ?>>>();

    proxyLock.readLock().lock();
    try {
      for (Map.Entry<RawEntity<?>, EntityProxy<? extends RawEntity<?>, ?>> proxy :
          proxies.entrySet()) {
        toFlush.add(proxy);
      }
    } finally {
      proxyLock.readLock().unlock();
    }

    for (Map.Entry<RawEntity<?>, EntityProxy<? extends RawEntity<?>, ?>> entry : toFlush) {
      entry.getValue().flushCache(entry.getKey());
    }

    relationsCache.flush();
  }