Search in sources :

Example 1 with EntityReturnImpl

use of org.hibernate.loader.plan.build.internal.returns.EntityReturnImpl in project hibernate-orm by hibernate.

the class AbstractLoadPlanBuildingAssociationVisitationStrategy method startingEntity.

// Entities  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@Override
public void startingEntity(EntityDefinition entityDefinition) {
    // see if the EntityDefinition is a root...
    final boolean isRoot = fetchSourceStack.isEmpty();
    if (!isRoot) {
        // if not, this call should represent a fetch which should have been handled in #startingAttribute
        return;
    }
    // if we get here, it is a root
    log.tracef("%s Starting root entity : %s", StringHelper.repeat(">>", fetchSourceStack.size()), entityDefinition.getEntityPersister().getEntityName());
    if (!supportsRootEntityReturns()) {
        throw new HibernateException("This strategy does not support root entity returns");
    }
    final EntityReturnImpl entityReturn = new EntityReturnImpl(entityDefinition, querySpaces);
    addRootReturn(entityReturn);
    pushToStack(entityReturn);
    // also add an AssociationKey for the root so we can later on recognize circular references back to the root.
    final Joinable entityPersister = (Joinable) entityDefinition.getEntityPersister();
    associationKeyRegistered(new AssociationKey(entityPersister.getTableName(), entityPersister.getKeyColumnNames()));
}
Also used : AssociationKey(org.hibernate.persister.walking.spi.AssociationKey) HibernateException(org.hibernate.HibernateException) Joinable(org.hibernate.persister.entity.Joinable) EntityReturnImpl(org.hibernate.loader.plan.build.internal.returns.EntityReturnImpl)

Aggregations

HibernateException (org.hibernate.HibernateException)1 EntityReturnImpl (org.hibernate.loader.plan.build.internal.returns.EntityReturnImpl)1 Joinable (org.hibernate.persister.entity.Joinable)1 AssociationKey (org.hibernate.persister.walking.spi.AssociationKey)1