Example usage for org.hibernate.internal SessionImpl getFactory

List of usage examples for org.hibernate.internal SessionImpl getFactory

Introduction

In this page you can find the example usage for org.hibernate.internal SessionImpl getFactory.

Prototype

SessionFactoryImplementor getFactory();

Source Link

Document

Get the creating SessionFactoryImplementor

Usage

From source file:br.gov.jfrj.siga.model.Objeto.java

License:Open Source License

private static void cascadeOrphans(Objeto base, PersistentCollection persistentCollection, boolean willBeSaved)
        throws UnexpectedException {
    SessionImpl session = ((SessionImpl) em().getDelegate());
    PersistenceContext pc = session.getPersistenceContext();
    CollectionEntry ce = pc.getCollectionEntry(persistentCollection);

    if (ce != null) {
        CollectionPersister cp = ce.getLoadedPersister();
        if (cp != null) {
            Type ct = cp.getElementType();
            if (ct instanceof EntityType) {
                EntityEntry entry = pc.getEntry(base);
                String entityName = entry.getEntityName();
                entityName = ((EntityType) ct).getAssociatedEntityName(session.getFactory());
                if (ce.getSnapshot() != null) {
                    Collection orphans = ce.getOrphans(entityName, persistentCollection);
                    for (Object o : orphans) {
                        saveAndCascadeIfObjeto(o, willBeSaved);
                    }/*from w  w w  . jav a  2 s  . c  o  m*/
                }
            }
        }
    }
}