Search in sources :

Example 1 with NamedEntityGraphDefinition

use of org.hibernate.cfg.annotations.NamedEntityGraphDefinition in project hibernate-orm by hibernate.

the class InFlightMetadataCollectorImpl method addNamedEntityGraph.

@Override
public void addNamedEntityGraph(NamedEntityGraphDefinition definition) {
    final String name = definition.getRegisteredName();
    final NamedEntityGraphDefinition previous = namedEntityGraphMap.put(name, definition);
    if (previous != null) {
        throw new DuplicateMappingException(DuplicateMappingException.Type.NAMED_ENTITY_GRAPH, name);
    }
}
Also used : NamedEntityGraphDefinition(org.hibernate.cfg.annotations.NamedEntityGraphDefinition) DuplicateMappingException(org.hibernate.DuplicateMappingException)

Example 2 with NamedEntityGraphDefinition

use of org.hibernate.cfg.annotations.NamedEntityGraphDefinition in project hibernate-orm by hibernate.

the class Configuration method reset.

protected void reset() {
    implicitNamingStrategy = ImplicitNamingStrategyJpaCompliantImpl.INSTANCE;
    physicalNamingStrategy = PhysicalNamingStrategyStandardImpl.INSTANCE;
    namedQueries = new HashMap<String, NamedQueryDefinition>();
    namedSqlQueries = new HashMap<String, NamedSQLQueryDefinition>();
    sqlResultSetMappings = new HashMap<String, ResultSetMappingDefinition>();
    namedEntityGraphMap = new HashMap<String, NamedEntityGraphDefinition>();
    namedProcedureCallMap = new HashMap<String, NamedProcedureCallDefinition>();
    standardServiceRegistryBuilder = new StandardServiceRegistryBuilder(bootstrapServiceRegistry);
    entityTuplizerFactory = new EntityTuplizerFactory();
    interceptor = EmptyInterceptor.INSTANCE;
    properties = new Properties();
    properties.putAll(standardServiceRegistryBuilder.getSettings());
}
Also used : StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) NamedQueryDefinition(org.hibernate.engine.spi.NamedQueryDefinition) Properties(java.util.Properties) NamedProcedureCallDefinition(org.hibernate.cfg.annotations.NamedProcedureCallDefinition) NamedEntityGraphDefinition(org.hibernate.cfg.annotations.NamedEntityGraphDefinition) NamedSQLQueryDefinition(org.hibernate.engine.spi.NamedSQLQueryDefinition) EntityTuplizerFactory(org.hibernate.tuple.entity.EntityTuplizerFactory) ResultSetMappingDefinition(org.hibernate.engine.ResultSetMappingDefinition)

Example 3 with NamedEntityGraphDefinition

use of org.hibernate.cfg.annotations.NamedEntityGraphDefinition in project hibernate-orm by hibernate.

the class MetamodelImpl method applyNamedEntityGraphs.

@SuppressWarnings("unchecked")
private void applyNamedEntityGraphs(java.util.Collection<NamedEntityGraphDefinition> namedEntityGraphs) {
    for (NamedEntityGraphDefinition definition : namedEntityGraphs) {
        log.debugf("Applying named entity graph [name=%s, entity-name=%s, jpa-entity-name=%s", definition.getRegisteredName(), definition.getEntityName(), definition.getJpaEntityName());
        final EntityType entityType = entity(definition.getEntityName());
        if (entityType == null) {
            throw new IllegalArgumentException("Attempted to register named entity graph [" + definition.getRegisteredName() + "] for unknown entity [" + definition.getEntityName() + "]");
        }
        final EntityGraphImpl entityGraph = new EntityGraphImpl(definition.getRegisteredName(), entityType, this.getSessionFactory());
        final NamedEntityGraph namedEntityGraph = definition.getAnnotation();
        if (namedEntityGraph.includeAllAttributes()) {
            for (Object attributeObject : entityType.getAttributes()) {
                entityGraph.addAttributeNodes((Attribute) attributeObject);
            }
        }
        if (namedEntityGraph.attributeNodes() != null) {
            applyNamedAttributeNodes(namedEntityGraph.attributeNodes(), namedEntityGraph, entityGraph);
        }
        entityGraphMap.put(definition.getRegisteredName(), entityGraph);
    }
}
Also used : NamedEntityGraphDefinition(org.hibernate.cfg.annotations.NamedEntityGraphDefinition) EntityType(javax.persistence.metamodel.EntityType) EntityGraphImpl(org.hibernate.jpa.graph.internal.EntityGraphImpl) NamedEntityGraph(javax.persistence.NamedEntityGraph)

Aggregations

NamedEntityGraphDefinition (org.hibernate.cfg.annotations.NamedEntityGraphDefinition)3 Properties (java.util.Properties)1 NamedEntityGraph (javax.persistence.NamedEntityGraph)1 EntityType (javax.persistence.metamodel.EntityType)1 DuplicateMappingException (org.hibernate.DuplicateMappingException)1 StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)1 NamedProcedureCallDefinition (org.hibernate.cfg.annotations.NamedProcedureCallDefinition)1 ResultSetMappingDefinition (org.hibernate.engine.ResultSetMappingDefinition)1 NamedQueryDefinition (org.hibernate.engine.spi.NamedQueryDefinition)1 NamedSQLQueryDefinition (org.hibernate.engine.spi.NamedSQLQueryDefinition)1 EntityGraphImpl (org.hibernate.jpa.graph.internal.EntityGraphImpl)1 EntityTuplizerFactory (org.hibernate.tuple.entity.EntityTuplizerFactory)1