Search in sources :

Example 1 with DuplicateMappingException

use of org.hibernate.DuplicateMappingException 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 DuplicateMappingException

use of org.hibernate.DuplicateMappingException in project hibernate-orm by hibernate.

the class InFlightMetadataCollectorImpl method addDenormalizedTable.

@Override
public Table addDenormalizedTable(String schemaName, String catalogName, String name, boolean isAbstract, String subselectFragment, Table includedTable) throws DuplicateMappingException {
    final Namespace namespace = getDatabase().locateNamespace(getDatabase().toIdentifier(catalogName), getDatabase().toIdentifier(schemaName));
    // annotation binding depends on the "table name" for @Subselect bindings
    // being set into the generated table (mainly to avoid later NPE), but for now we need to keep that :(
    final Identifier logicalName;
    if (name != null) {
        logicalName = getDatabase().toIdentifier(name);
    } else {
        logicalName = null;
    }
    if (subselectFragment != null) {
        return new DenormalizedTable(namespace, logicalName, subselectFragment, isAbstract, includedTable);
    } else {
        Table table = namespace.locateTable(logicalName);
        if (table != null) {
            throw new DuplicateMappingException(DuplicateMappingException.Type.TABLE, logicalName.toString());
        } else {
            table = namespace.createDenormalizedTable(logicalName, isAbstract, includedTable);
        }
        return table;
    }
}
Also used : Identifier(org.hibernate.boot.model.naming.Identifier) DenormalizedTable(org.hibernate.mapping.DenormalizedTable) DenormalizedTable(org.hibernate.mapping.DenormalizedTable) Table(org.hibernate.mapping.Table) DuplicateMappingException(org.hibernate.DuplicateMappingException) Namespace(org.hibernate.boot.model.relational.Namespace)

Example 3 with DuplicateMappingException

use of org.hibernate.DuplicateMappingException in project hibernate-orm by hibernate.

the class InFlightMetadataCollectorImpl method addNamedProcedureCallDefinition.

@Override
public void addNamedProcedureCallDefinition(NamedProcedureCallDefinition definition) {
    if (definition == null) {
        throw new IllegalArgumentException("Named query definition is null");
    }
    final String name = definition.getRegisteredName();
    if (defaultNamedProcedureNames.contains(name)) {
        return;
    }
    final NamedProcedureCallDefinition previous = namedProcedureCallMap.put(name, definition);
    if (previous != null) {
        throw new DuplicateMappingException(DuplicateMappingException.Type.PROCEDURE, name);
    }
}
Also used : DuplicateMappingException(org.hibernate.DuplicateMappingException) NamedProcedureCallDefinition(org.hibernate.cfg.annotations.NamedProcedureCallDefinition)

Aggregations

DuplicateMappingException (org.hibernate.DuplicateMappingException)3 Identifier (org.hibernate.boot.model.naming.Identifier)1 Namespace (org.hibernate.boot.model.relational.Namespace)1 NamedEntityGraphDefinition (org.hibernate.cfg.annotations.NamedEntityGraphDefinition)1 NamedProcedureCallDefinition (org.hibernate.cfg.annotations.NamedProcedureCallDefinition)1 DenormalizedTable (org.hibernate.mapping.DenormalizedTable)1 Table (org.hibernate.mapping.Table)1