Search in sources :

Example 1 with CompositeTypeImplementor

use of org.hibernate.type.spi.CompositeTypeImplementor in project hibernate-orm by hibernate.

the class EmbeddableMappingTypeImpl method from.

public static EmbeddableMappingTypeImpl from(Component bootDescriptor, CompositeType compositeType, String rootTableExpression, String[] rootTableKeyColumnNames, Function<EmbeddableMappingType, EmbeddableValuedModelPart> embeddedPartBuilder, MappingModelCreationProcess creationProcess) {
    final RuntimeModelCreationContext creationContext = creationProcess.getCreationContext();
    final EmbeddableMappingTypeImpl mappingType = new EmbeddableMappingTypeImpl(bootDescriptor, embeddedPartBuilder, creationContext);
    if (compositeType instanceof CompositeTypeImplementor) {
        ((CompositeTypeImplementor) compositeType).injectMappingModelPart(mappingType.getEmbeddedValueMapping(), creationProcess);
    }
    creationProcess.registerInitializationCallback("EmbeddableMappingType(" + mappingType.getNavigableRole().getFullPath() + ")#finishInitialization", () -> mappingType.finishInitialization(bootDescriptor, compositeType, rootTableExpression, rootTableKeyColumnNames, creationProcess));
    return mappingType;
}
Also used : CompositeTypeImplementor(org.hibernate.type.spi.CompositeTypeImplementor) RuntimeModelCreationContext(org.hibernate.metamodel.spi.RuntimeModelCreationContext)

Example 2 with CompositeTypeImplementor

use of org.hibernate.type.spi.CompositeTypeImplementor in project hibernate-orm by hibernate.

the class ComponentBasicProxyTest method testOnlyOneProxyClassGenerated.

@Test
@TestForIssue(jiraKey = "HHH-12791")
public void testOnlyOneProxyClassGenerated(DomainModelScope domainModelScope, SessionFactoryScope sfScope) {
    final SessionFactoryImplementor sessionFactory = sfScope.getSessionFactory();
    final PersistentClass personDescriptor = domainModelScope.getDomainModel().getEntityBinding(Person.class.getName());
    final CompositeTypeImplementor componentType = (CompositeTypeImplementor) personDescriptor.getIdentifierMapper().getType();
    final EmbeddableValuedModelPart embedded = componentType.getMappingModelPart();
    final EmbeddableInstantiator instantiator = embedded.getEmbeddableTypeDescriptor().getRepresentationStrategy().getInstantiator();
    final Object instance1 = instantiator.instantiate(null, sessionFactory);
    final Object instance2 = instantiator.instantiate(null, sessionFactory);
    assertThat(instance1.getClass()).isEqualTo(instance2.getClass());
}
Also used : CompositeTypeImplementor(org.hibernate.type.spi.CompositeTypeImplementor) SessionFactoryImplementor(org.hibernate.engine.spi.SessionFactoryImplementor) EmbeddableValuedModelPart(org.hibernate.metamodel.mapping.EmbeddableValuedModelPart) EmbeddableInstantiator(org.hibernate.metamodel.spi.EmbeddableInstantiator) PersistentClass(org.hibernate.mapping.PersistentClass) Test(org.junit.jupiter.api.Test) TestForIssue(org.hibernate.testing.TestForIssue)

Aggregations

CompositeTypeImplementor (org.hibernate.type.spi.CompositeTypeImplementor)2 SessionFactoryImplementor (org.hibernate.engine.spi.SessionFactoryImplementor)1 PersistentClass (org.hibernate.mapping.PersistentClass)1 EmbeddableValuedModelPart (org.hibernate.metamodel.mapping.EmbeddableValuedModelPart)1 EmbeddableInstantiator (org.hibernate.metamodel.spi.EmbeddableInstantiator)1 RuntimeModelCreationContext (org.hibernate.metamodel.spi.RuntimeModelCreationContext)1 TestForIssue (org.hibernate.testing.TestForIssue)1 Test (org.junit.jupiter.api.Test)1