Example usage for org.hibernate.persister.entity EntityPersister hasCascades

List of usage examples for org.hibernate.persister.entity EntityPersister hasCascades

Introduction

In this page you can find the example usage for org.hibernate.persister.entity EntityPersister hasCascades.

Prototype

boolean hasCascades();

Source Link

Document

Determine whether this entity has any non-none cascading.

Usage

From source file:com.miranteinfo.seam.hibernate.HibernateCascade.java

License:Open Source License

/**
 * Cascade an action from the parent entity instance to all its children.  This
 * form is typicaly called from within cascade actions.
 *
 * @param persister The parent's entity persister
 * @param parent The parent reference.//ww  w. j  a  v  a  2s .  c  o m
 * @param anything Anything ;)   Typically some form of cascade-local cache
 * which is specific to each CascadingAction type
 * @throws HibernateException
 */
public void cascade(final EntityPersister persister, final Object parent, final Object anything)
        throws HibernateException {

    if (persister.hasCascades() || action.requiresNoCascadeChecking()) { // performance opt
        if (log.isTraceEnabled()) {
            log.trace("processing cascade " + action + " for: " + persister.getEntityName());
        }

        Type[] types = persister.getPropertyTypes();
        CascadeStyle[] cascadeStyles = persister.getPropertyCascadeStyles();
        EntityMode entityMode = eventSource.getEntityMode();
        boolean hasUninitializedLazyProperties = persister.hasUninitializedLazyProperties(parent, entityMode);
        for (int i = 0; i < types.length; i++) {
            CascadeStyle style = cascadeStyles[i];
            if (hasUninitializedLazyProperties && persister.getPropertyLaziness()[i]
                    && !action.performOnLazyProperty()) {
                //do nothing to avoid a lazy property initialization
                continue;
            }

            if (style.doCascade(action)) {
                cascadeProperty(persister.getPropertyValue(parent, i, entityMode), types[i], style, anything,
                        false);
            } else if (action.requiresNoCascadeChecking()) {
                action.noCascade(eventSource, persister.getPropertyValue(parent, i, entityMode), parent,
                        persister, i);
            }
        }

        if (log.isTraceEnabled()) {
            log.trace("done processing cascade " + action + " for: " + persister.getEntityName());
        }
    }
}