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

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

Introduction

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

Prototype

boolean[] getPropertyLaziness();

Source Link

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./*from ww w.  j  a  v a2 s.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());
        }
    }
}