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()));
}
}
Aggregations