Example usage for org.hibernate.collection.internal AbstractPersistentCollection forceInitialization

List of usage examples for org.hibernate.collection.internal AbstractPersistentCollection forceInitialization

Introduction

In this page you can find the example usage for org.hibernate.collection.internal AbstractPersistentCollection forceInitialization.

Prototype

@Override
    public final void forceInitialization() throws HibernateException 

Source Link

Usage

From source file:ch.algotrader.dao.HibernateInitializer.java

License:Open Source License

@Override
public <T extends BaseEntityI, C extends Collection<T>> C initializeCollection(BaseEntityI entity,
        String context, C col) {//from w  w w.  j a  v a 2 s.  c o  m

    if (col instanceof AbstractPersistentCollection) {

        AbstractPersistentCollection persistentCol = (AbstractPersistentCollection) col;
        if (!persistentCol.wasInitialized()) {
            if (persistentCol.getSession() != null) {

                long before = System.nanoTime();
                persistentCol.forceInitialization();
                MetricsUtil.account(ClassUtils.getShortClassName(entity.getClass()) + context, (before));
            } else {
                throw new IllegalStateException("no hibernate session available");
            }
        }
    }

    return col;
}