minor change

- initialize `#valueMapping` field during `org.hibernate.metamodel.mapping.EmbeddableMappingType` ctor by passing along the creator-function, allowing `#valueMapping` to become physically final (was always logically final).
This commit is contained in:
Steve Ebersole 2019-12-07 08:38:40 -06:00
parent d5125d8e31
commit 033eea4258
1 changed files with 9 additions and 10 deletions

View File

@ -58,11 +58,10 @@ public class EmbeddableMappingType implements ManagedMappingType {
final EmbeddableMappingType mappingType = new EmbeddableMappingType(
bootDescriptor,
representationStrategy,
embeddedPartBuilder,
creationContext.getSessionFactory()
);
mappingType.valueMapping = embeddedPartBuilder.apply( mappingType );
creationProcess.registerInitializationCallback(
() -> mappingType.finishInitialization(
bootDescriptor,
@ -81,20 +80,20 @@ public class EmbeddableMappingType implements ManagedMappingType {
private final SortedMap<String,AttributeMapping> attributeMappings = new TreeMap<>();
/**
* This is logically final. However given the chicken-and-egg situation between
* EmbeddableMappingType and EmbeddableValuedModelPart one side will need to be
* physically non-final
*/
private EmbeddableValuedModelPart valueMapping;
private final EmbeddableValuedModelPart valueMapping;
public EmbeddableMappingType(
Component bootDescriptor,
private EmbeddableMappingType(
@SuppressWarnings("unused") Component bootDescriptor,
EmbeddableRepresentationStrategy representationStrategy,
Function<EmbeddableMappingType, EmbeddableValuedModelPart> embeddedPartBuilder,
SessionFactoryImplementor sessionFactory) {
this.embeddableJtd = representationStrategy.getMappedJavaTypeDescriptor();
this.representationStrategy = representationStrategy;
this.sessionFactory = sessionFactory;
this.valueMapping = embeddedPartBuilder.apply( this );
}
private boolean finishInitialization(