Source:
<code>public static SingularAssociationAttributeMapping buildSingularAssociationAttributeMapping( String attrName, int stateArrayPosition, Property bootProperty, ManagedMappingType declaringType, EntityType attrType, PropertyAccess propertyAccess, CascadeStyle cascadeStyle, MappingModelCreationProcess creationProcess) { ToOne value = (ToOne) bootProperty.getValue(); final EntityPersister entityPersister = creationProcess.getEntityPersister( value.getReferencedEntityName() ); final StateArrayContributorMetadataAccess stateArrayContributorMetadataAccess = getStateArrayContributorMetadataAccess( bootProperty, attrType, propertyAccess, cascadeStyle, creationProcess ); SessionFactoryImplementor sessionFactory = creationProcess.getCreationContext().getSessionFactory(); final AssociationType type = (AssociationType) bootProperty.getType(); final FetchStyle fetchStyle = FetchStrategyHelper .determineFetchStyleByMetadata( bootProperty.getValue().getFetchMode(), type, sessionFactory ); final FetchTiming fetchTiming; <START> if ( !( (ToOne) bootProperty.getValue() ).isLazy() ) { <END> fetchTiming = FetchTiming.IMMEDIATE; } else { fetchTiming = FetchStrategyHelper.determineFetchTiming( fetchStyle, type, sessionFactory ); } final FetchStrategy fetchStrategy = new FetchStrategy( fetchTiming, fetchStyle ); final SingularAssociationAttributeMapping attributeMapping = new SingularAssociationAttributeMapping( attrName, stateArrayPosition, (ToOne) bootProperty.getValue(), stateArrayContributorMetadataAccess, fetchStrategy, entityPersister, declaringType, propertyAccess ); creationProcess.registerInitializationCallback( () -> { final Dialect dialect = creationProcess.getCreationContext() .getSessionFactory() .getJdbcServices() .getDialect(); MappingModelCreationHelper.interpretKeyDescriptor( attributeMapping, bootProperty, (ToOne) bootProperty.getValue(), declaringType.findContainingEntityMapping(), dialect, creationProcess ); return true; } ); return attributeMapping; }</code><technical_language>Is true casting is valid triggering exception</technical_language>

Target:
public static SingularAssociationAttributeMapping buildSingularAssociationAttributeMapping( String attrName, int stateArrayPosition, Property bootProperty, ManagedMappingType declaringType, EntityType attrType, PropertyAccess propertyAccess, CascadeStyle cascadeStyle, MappingModelCreationProcess creationProcess) { if ( bootProperty.getValue() instanceof ToOne ) { final ToOne value = (ToOne) bootProperty.getValue(); final EntityPersister entityPersister = creationProcess.getEntityPersister( value.getReferencedEntityName() ); final StateArrayContributorMetadataAccess stateArrayContributorMetadataAccess = getStateArrayContributorMetadataAccess( bootProperty, attrType, propertyAccess, cascadeStyle, creationProcess ); SessionFactoryImplementor sessionFactory = creationProcess.getCreationContext().getSessionFactory(); final AssociationType type = (AssociationType) bootProperty.getType(); final FetchStyle fetchStyle = FetchStrategyHelper .determineFetchStyleByMetadata( bootProperty.getValue().getFetchMode(), type, sessionFactory ); final FetchTiming fetchTiming; if ( fetchStyle == fetchStyle.JOIN || ( value instanceof OneToOne && value.isNullable() ) || !( value ).isLazy() ) { fetchTiming = FetchTiming.IMMEDIATE; } else { fetchTiming = FetchStrategyHelper.determineFetchTiming( fetchStyle, type, sessionFactory ); } final FetchStrategy fetchStrategy = new FetchStrategy( fetchTiming, fetchStyle ); final SingularAssociationAttributeMapping attributeMapping = new SingularAssociationAttributeMapping( attrName, stateArrayPosition, (ToOne) bootProperty.getValue(), stateArrayContributorMetadataAccess, fetchStrategy, entityPersister, declaringType, propertyAccess ); creationProcess.registerInitializationCallback( () -> { final Dialect dialect = creationProcess.getCreationContext() .getSessionFactory() .getJdbcServices() .getDialect(); MappingModelCreationHelper.interpretKeyDescriptor( attributeMapping, bootProperty, (ToOne) bootProperty.getValue(), declaringType.findContainingEntityMapping(), dialect, creationProcess ); return true; } ); return attributeMapping; } else { throw new NotYetImplementedFor6Exception( "AnyType support has not yet been implemented" ); } }