HHH-6911 - Write DiscriminatorValue to DiscriminatorColumn when combined with InheritanceType#JOINED
This commit is contained in:
parent
faba70203a
commit
26820e8a77
|
@ -900,8 +900,32 @@ public final class AnnotationBinder {
|
||||||
// we want to process the discriminator column if either:
|
// we want to process the discriminator column if either:
|
||||||
// 1) There is an explicit DiscriminatorColumn annotation && we are not told to ignore them
|
// 1) There is an explicit DiscriminatorColumn annotation && we are not told to ignore them
|
||||||
// 2) There is not an explicit DiscriminatorColumn annotation && we are told to create them implicitly
|
// 2) There is not an explicit DiscriminatorColumn annotation && we are told to create them implicitly
|
||||||
if ( ( discriminatorColumnAnnotation != null && !mappings.ignoreExplicitDiscriminatorColumnForJoinedInheritance() )
|
final boolean generateDiscriminatorColumn;
|
||||||
|| ( discriminatorColumnAnnotation == null && mappings.useImplicitDiscriminatorColumnForJoinedInheritance() ) ) {
|
if ( discriminatorColumnAnnotation != null ) {
|
||||||
|
if ( mappings.ignoreExplicitDiscriminatorColumnForJoinedInheritance() ) {
|
||||||
|
LOG.debugf( "Ignoring explicit DiscriminatorColumn annotation on ", clazzToProcess.getName() );
|
||||||
|
generateDiscriminatorColumn = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LOG.applyingExplicitDiscriminatorColumnForJoined(
|
||||||
|
clazzToProcess.getName(),
|
||||||
|
AvailableSettings.IGNORE_EXPLICIT_DISCRIMINATOR_COLUMNS_FOR_JOINED_SUBCLASS
|
||||||
|
);
|
||||||
|
generateDiscriminatorColumn = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ( mappings.useImplicitDiscriminatorColumnForJoinedInheritance() ) {
|
||||||
|
LOG.debug( "Applying implicit DiscriminatorColumn using DiscriminatorColumn defaults" );
|
||||||
|
generateDiscriminatorColumn = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LOG.debug( "Ignoring implicit (absent) DiscriminatorColumn" );
|
||||||
|
generateDiscriminatorColumn = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( generateDiscriminatorColumn ) {
|
||||||
final DiscriminatorType discriminatorType = discriminatorColumnAnnotation != null
|
final DiscriminatorType discriminatorType = discriminatorColumnAnnotation != null
|
||||||
? discriminatorColumnAnnotation.discriminatorType()
|
? discriminatorColumnAnnotation.discriminatorType()
|
||||||
: DiscriminatorType.STRING;
|
: DiscriminatorType.STRING;
|
||||||
|
|
|
@ -1665,4 +1665,13 @@ public interface CoreMessageLogger extends BasicLogger {
|
||||||
@Message(value = "Named parameters are used for a callable statement, but database metadata indicates named parameters are not supported.", id = 456)
|
@Message(value = "Named parameters are used for a callable statement, but database metadata indicates named parameters are not supported.", id = 456)
|
||||||
void unsupportedNamedParameters();
|
void unsupportedNamedParameters();
|
||||||
|
|
||||||
|
@LogMessage(level = WARN)
|
||||||
|
@Message(
|
||||||
|
id = 457,
|
||||||
|
value = "Joined inheritance hierarchy [%1$s] defined explicit @DiscriminatorColumn. Legacy Hibernate behavior " +
|
||||||
|
"was to ignore the @DiscriminatorColumn. However, as part of issue HHH-6911 we now apply the " +
|
||||||
|
"explicit @DiscriminatorColumn. If you would prefer the legacy behavior, enable the `%2$s` setting " +
|
||||||
|
"(%2$s=true)"
|
||||||
|
)
|
||||||
|
void applyingExplicitDiscriminatorColumnForJoined(String className, String overrideSetting);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue