Search in sources :

Example 1 with NullableDiscriminatorColumnSecondPass

use of org.hibernate.cfg.internal.NullableDiscriminatorColumnSecondPass in project hibernate-orm by hibernate.

the class AnnotationBinder method bindDiscriminatorColumnToRootPersistentClass.

private static void bindDiscriminatorColumnToRootPersistentClass(RootClass rootClass, AnnotatedDiscriminatorColumn discriminatorColumn, Map<String, Join> secondaryTables, PropertyHolder propertyHolder, MetadataBuildingContext context) {
    if (rootClass.getDiscriminator() == null) {
        if (discriminatorColumn == null) {
            throw new AssertionFailure("discriminator column should have been built");
        }
        discriminatorColumn.setJoins(secondaryTables);
        discriminatorColumn.setPropertyHolder(propertyHolder);
        BasicValue discriminatorColumnBinding = new BasicValue(context, rootClass.getTable());
        rootClass.setDiscriminator(discriminatorColumnBinding);
        discriminatorColumn.linkWithValue(discriminatorColumnBinding);
        discriminatorColumnBinding.setTypeName(discriminatorColumn.getDiscriminatorTypeName());
        rootClass.setPolymorphic(true);
        if (LOG.isTraceEnabled()) {
            LOG.tracev("Setting discriminator for entity {0}", rootClass.getEntityName());
        }
        context.getMetadataCollector().addSecondPass(new NullableDiscriminatorColumnSecondPass(rootClass.getEntityName()));
    }
}
Also used : NullableDiscriminatorColumnSecondPass(org.hibernate.cfg.internal.NullableDiscriminatorColumnSecondPass) AssertionFailure(org.hibernate.AssertionFailure) BasicValue(org.hibernate.mapping.BasicValue)

Aggregations

AssertionFailure (org.hibernate.AssertionFailure)1 NullableDiscriminatorColumnSecondPass (org.hibernate.cfg.internal.NullableDiscriminatorColumnSecondPass)1 BasicValue (org.hibernate.mapping.BasicValue)1