Search in sources :

Example 1 with EntityGraphImplementor

use of org.hibernate.graph.spi.EntityGraphImplementor in project hibernate-orm by hibernate.

the class SessionImpl method createEntityGraph.

@Override
public EntityGraph<?> createEntityGraph(String graphName) {
    checkOpen();
    final EntityGraph named = getEntityManagerFactory().findEntityGraphByName(graphName);
    if (named == null) {
        return null;
    }
    if (EntityGraphImplementor.class.isInstance(named)) {
        return ((EntityGraphImplementor) named).makeMutableCopy();
    } else {
        return named;
    }
}
Also used : EntityGraph(javax.persistence.EntityGraph) EntityGraphImplementor(org.hibernate.graph.spi.EntityGraphImplementor)

Example 2 with EntityGraphImplementor

use of org.hibernate.graph.spi.EntityGraphImplementor in project hibernate-orm by hibernate.

the class MetamodelImpl method findEntityGraphsByType.

@Override
@SuppressWarnings("unchecked")
public <T> List<EntityGraph<? super T>> findEntityGraphsByType(Class<T> entityClass) {
    final EntityType<T> entityType = entity(entityClass);
    if (entityType == null) {
        throw new IllegalArgumentException("Given class is not an entity : " + entityClass.getName());
    }
    final List<EntityGraph<? super T>> results = new ArrayList<>();
    for (EntityGraph entityGraph : entityGraphMap.values()) {
        if (!EntityGraphImplementor.class.isInstance(entityGraph)) {
            continue;
        }
        final EntityGraphImplementor egi = (EntityGraphImplementor) entityGraph;
        if (egi.appliesTo(entityType)) {
            results.add(egi);
        }
    }
    return results;
}
Also used : EntityGraph(javax.persistence.EntityGraph) NamedEntityGraph(javax.persistence.NamedEntityGraph) ArrayList(java.util.ArrayList) EntityGraphImplementor(org.hibernate.graph.spi.EntityGraphImplementor)

Aggregations

EntityGraph (javax.persistence.EntityGraph)2 EntityGraphImplementor (org.hibernate.graph.spi.EntityGraphImplementor)2 ArrayList (java.util.ArrayList)1 NamedEntityGraph (javax.persistence.NamedEntityGraph)1