Example usage for org.hibernate.engine.spi EntityEntry getEntityName

List of usage examples for org.hibernate.engine.spi EntityEntry getEntityName

Introduction

In this page you can find the example usage for org.hibernate.engine.spi EntityEntry getEntityName.

Prototype

String getEntityName();

Source Link

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  ww.  ja v a  2s  .  c  om
                }
            }
        }
    }
}