Search in sources :

Example 1 with TableOwner

use of org.hibernate.mapping.TableOwner in project hibernate-orm by hibernate.

the class EntityBinder method bindTable.

public void bindTable(String schema, String catalog, String tableName, List<UniqueConstraintHolder> uniqueConstraints, String constraints, InFlightMetadataCollector.EntityTableXref denormalizedSuperTableXref) {
    EntityTableNamingStrategyHelper namingStrategyHelper = new EntityTableNamingStrategyHelper(persistentClass.getClassName(), persistentClass.getEntityName(), name);
    final Identifier logicalName;
    if (StringHelper.isNotEmpty(tableName)) {
        logicalName = namingStrategyHelper.handleExplicitName(tableName, context);
    } else {
        logicalName = namingStrategyHelper.determineImplicitName(context);
    }
    final Table table = TableBinder.buildAndFillTable(schema, catalog, logicalName, persistentClass.isAbstract(), uniqueConstraints, null, constraints, context, this.subselect, denormalizedSuperTableXref);
    final RowId rowId = annotatedClass.getAnnotation(RowId.class);
    if (rowId != null) {
        table.setRowId(rowId.value());
    }
    context.getMetadataCollector().addEntityTableXref(persistentClass.getEntityName(), logicalName, table, denormalizedSuperTableXref);
    if (persistentClass instanceof TableOwner) {
        LOG.debugf("Bind entity %s on table %s", persistentClass.getEntityName(), table.getName());
        ((TableOwner) persistentClass).setTable(table);
    } else {
        throw new AssertionFailure("binding a table for a subclass");
    }
}
Also used : TableOwner(org.hibernate.mapping.TableOwner) RowId(org.hibernate.annotations.RowId) Identifier(org.hibernate.boot.model.naming.Identifier) JoinTable(javax.persistence.JoinTable) SecondaryTable(javax.persistence.SecondaryTable) Table(org.hibernate.mapping.Table) AssertionFailure(org.hibernate.AssertionFailure)

Aggregations

JoinTable (javax.persistence.JoinTable)1 SecondaryTable (javax.persistence.SecondaryTable)1 AssertionFailure (org.hibernate.AssertionFailure)1 RowId (org.hibernate.annotations.RowId)1 Identifier (org.hibernate.boot.model.naming.Identifier)1 Table (org.hibernate.mapping.Table)1 TableOwner (org.hibernate.mapping.TableOwner)1