Search in sources :

Example 1 with IdentityMap

use of org.hibernate.internal.util.collections.IdentityMap in project hibernate-orm by hibernate.

the class AbstractFlushingEventListener method prepareEntityFlushes.

/**
 * process cascade save/update at the start of a flush to discover
 * any newly referenced entity that must be passed to saveOrUpdate(),
 * and also apply orphan delete
 */
private void prepareEntityFlushes(EventSource session, PersistenceContext persistenceContext) throws HibernateException {
    LOG.debug("Processing flush-time cascades");
    final Object anything = getAnything();
    // safe from concurrent modification because of how concurrentEntries() is implemented on IdentityMap
    for (Map.Entry<Object, EntityEntry> me : persistenceContext.reentrantSafeEntityEntries()) {
        // for ( Map.Entry me : IdentityMap.concurrentEntries( persistenceContext.getEntityEntries() ) ) {
        EntityEntry entry = (EntityEntry) me.getValue();
        Status status = entry.getStatus();
        if (status == Status.MANAGED || status == Status.SAVING || status == Status.READ_ONLY) {
            cascadeOnFlush(session, entry.getPersister(), me.getKey(), anything);
        }
    }
}
Also used : Status(org.hibernate.engine.spi.Status) EntityEntry(org.hibernate.engine.spi.EntityEntry) Map(java.util.Map) IdentityMap(org.hibernate.internal.util.collections.IdentityMap) IdentityHashMap(java.util.IdentityHashMap)

Aggregations

IdentityHashMap (java.util.IdentityHashMap)1 Map (java.util.Map)1 EntityEntry (org.hibernate.engine.spi.EntityEntry)1 Status (org.hibernate.engine.spi.Status)1 IdentityMap (org.hibernate.internal.util.collections.IdentityMap)1