File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
hibernate-core/src/main/java/org/hibernate/metamodel/mapping Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 1313import org .hibernate .metamodel .model .domain .NavigableRole ;
1414import org .hibernate .metamodel .spi .MappingMetamodelImplementor ;
1515import org .hibernate .type .BasicType ;
16+ import org .hibernate .type .descriptor .java .CharacterJavaType ;
1617import org .hibernate .type .descriptor .java .JavaType ;
18+ import org .hibernate .type .descriptor .java .StringJavaType ;
1719
1820import java .util .List ;
1921import java .util .Map ;
@@ -113,6 +115,23 @@ public DiscriminatorValueDetails getDetailsForDiscriminatorValue(Object value) {
113115 return notNullMatch ;
114116 }
115117
118+ if ( value .getClass ().isEnum () ) {
119+ final Object enumValue ;
120+ if ( getRelationalJavaType () instanceof StringJavaType ) {
121+ enumValue = ( (Enum ) value ).name ();
122+ }
123+ else if ( getRelationalJavaType () instanceof CharacterJavaType ) {
124+ enumValue = ( (Enum ) value ).name ().charAt ( 0 );
125+ }
126+ else {
127+ enumValue = ( (Enum ) value ).ordinal ();
128+ }
129+ final DiscriminatorValueDetails enumMatch = discriminatorValueToEntityNameMap .get ( enumValue );
130+ if ( enumMatch != null ) {
131+ return enumMatch ;
132+ }
133+ }
134+
116135 throw new HibernateException ( "Unrecognized discriminator value: " + value );
117136 }
118137
You can’t perform that action at this time.
0 commit comments