HHH-12445 Fix ORM not detecting "null"/"not null" discriminator values correctly for joined inheritance

This commit is contained in:
Yoann Rodière 2021-05-03 18:11:29 +02:00
parent 7144af5990
commit 1a2510df16
1 changed files with 11 additions and 2 deletions

View File

@ -106,7 +106,7 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
// subclass discrimination works by assigning particular
// values to certain combinations of null primary key
// values in the outer join using an SQL CASE
private final Map subclassesByDiscriminatorValue = new HashMap();
private final Map<Object, String> subclassesByDiscriminatorValue = new HashMap<>();
private final String[] discriminatorValues;
private final String[] notNullColumnNames;
private final int[] notNullColumnTableNumbers;
@ -801,7 +801,16 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
}
public String getSubclassForDiscriminatorValue(Object value) {
return (String) subclassesByDiscriminatorValue.get( value );
if ( value == null ) {
return subclassesByDiscriminatorValue.get( NULL_DISCRIMINATOR );
}
else {
String result = subclassesByDiscriminatorValue.get( value );
if ( result == null ) {
result = subclassesByDiscriminatorValue.get( NOT_NULL_DISCRIMINATOR );
}
return result;
}
}
@Override