protected void bindDiscriminatorProperty ( Table table , RootClass entity , InFlightMetadataCollector mappings ) { Mapping m = getMapping ( entity . getMappedClass ( ) ) ; SimpleValue d = new SimpleValue ( metadataBuildingContext , table ) ; entity . setDiscriminator ( d ) ; DiscriminatorConfig discriminatorConfig = m != null ? m . getDiscriminator ( ) : null ; boolean hasDiscriminatorConfig = discriminatorConfig != null ; entity . setDiscriminatorValue ( hasDiscriminatorConfig ? discriminatorConfig . getValue ( ) : entity . getClassName ( ) ) ; if ( hasDiscriminatorConfig ) { if ( discriminatorConfig . getInsertable ( ) != null ) { entity . setDiscriminatorInsertable ( discriminatorConfig . getInsertable ( ) ) ; } Object type = discriminatorConfig . getType ( ) ; if ( type != null ) { if ( type instanceof Class ) { d . setTypeName ( ( ( Class ) type ) . getName ( ) ) ; } else { d . setTypeName ( type . toString ( ) ) ; } } } if ( hasDiscriminatorConfig && discriminatorConfig . getFormula ( ) != null ) { Formula formula = new Formula ( ) ; formula . setFormula ( discriminatorConfig . getFormula ( ) ) ; d . addFormula ( formula ) ; } else { bindSimpleValue ( STRING_TYPE , d , false , RootClass . DEFAULT_DISCRIMINATOR_COLUMN_NAME , mappings ) ; ColumnConfig cc = ! hasDiscriminatorConfig ? null : discriminatorConfig . getColumn ( ) ; if ( cc != null ) { Column c = ( Column ) d . getColumnIterator ( ) . next ( ) ; if ( cc . getName ( ) != null ) { c . setName ( cc . getName ( ) ) ; } bindColumnConfigToColumn ( null , c , cc ) ; } } entity . setPolymorphic ( true ) ; }
Creates and binds the discriminator property used in table - per - hierarchy inheritance to discriminate between sub class instances