@@ -1596,27 +1596,27 @@ private void processNamedEntityGraph(NamedEntityGraph annotation) {
15961596 public void bindDiscriminatorValue () {
15971597 final DiscriminatorValue discriminatorValueAnn =
15981598 annotatedClass .getAnnotationUsage ( DiscriminatorValue .class , getSourceModelContext () );
1599- final String discriminatorValue = discriminatorValueAnn != null
1600- ? discriminatorValueAnn .value ()
1601- : null ;
1602- if ( isBlank ( discriminatorValue ) ) {
1599+ if ( discriminatorValueAnn == null ) {
16031600 final Value discriminator = persistentClass .getDiscriminator ();
16041601 if ( discriminator == null ) {
16051602 persistentClass .setDiscriminatorValue ( name );
16061603 }
1607- else if ( "character" .equals ( discriminator .getType ().getName () ) ) {
1608- throw new AnnotationException ( "Entity '" + name
1609- + "' has a discriminator of character type and must specify its '@DiscriminatorValue'" );
1610- }
1611- else if ( "integer" .equals ( discriminator .getType ().getName () ) ) {
1612- persistentClass .setDiscriminatorValue ( String .valueOf ( name .hashCode () ) );
1613- }
16141604 else {
1615- persistentClass .setDiscriminatorValue ( name ); //Spec compliant
1605+ switch ( discriminator .getType ().getName () ) {
1606+ case "character" :
1607+ throw new AnnotationException ( "Entity '" + name
1608+ + "' has a discriminator of character type and must specify its '@DiscriminatorValue'" );
1609+ case "integer" :
1610+ // TODO: pretty nasty, should we just deprecate/disallow this?
1611+ persistentClass .setDiscriminatorValue ( String .valueOf ( name .hashCode () ) );
1612+ break ;
1613+ default :
1614+ persistentClass .setDiscriminatorValue ( name ); //Spec compliant
1615+ }
16161616 }
16171617 }
16181618 else {
1619- persistentClass .setDiscriminatorValue ( discriminatorValue );
1619+ persistentClass .setDiscriminatorValue ( discriminatorValueAnn . value () );
16201620 }
16211621 }
16221622
0 commit comments