org.hibernate.jpa.boot.spi.IntegratorProvider Java Examples

The following examples show how to use org.hibernate.jpa.boot.spi.IntegratorProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractTest.java    From hibernate-types with Apache License 2.0 6 votes vote down vote up
protected EntityManagerFactory newEntityManagerFactory() {
    PersistenceUnitInfo persistenceUnitInfo = persistenceUnitInfo(getClass().getSimpleName());
    Map<String, Object> configuration = new HashMap<String, Object>();
    configuration.put(AvailableSettings.INTERCEPTOR, interceptor());
    final Integrator integrator = integrator();
    if (integrator != null) {
        configuration.put(
            "hibernate.integrator_provider",
            new IntegratorProvider() {
                @Override
                public List<Integrator> getIntegrators() {
                    return Collections.singletonList(integrator);
                }
            }
        );
    }

    EntityManagerFactoryBuilderImpl entityManagerFactoryBuilder = new EntityManagerFactoryBuilderImpl(
            new PersistenceUnitInfoDescriptor(persistenceUnitInfo), configuration
    );
    return entityManagerFactoryBuilder.build();
}
 
Example #2
Source File: ResourceLocalReleaseAfterStatementConfiguration.java    From high-performance-java-persistence with Apache License 2.0 6 votes vote down vote up
protected Properties additionalProperties() {
    Properties properties = new Properties();
    properties.setProperty("hibernate.dialect", hibernateDialect);
    properties.setProperty("hibernate.hbm2ddl.auto", "create-drop");
    properties.put(
        "hibernate.integrator_provider",
            (IntegratorProvider) () -> Collections.singletonList(
                new ClassImportIntegrator(Arrays.asList(PostDTO.class))
            )
    );
    properties.put(
        AvailableSettings.CONNECTION_HANDLING,
        //PhysicalConnectionHandlingMode.DELAYED_ACQUISITION_AND_RELEASE_AFTER_STATEMENT
        PhysicalConnectionHandlingMode.DELAYED_ACQUISITION_AND_RELEASE_AFTER_TRANSACTION
    );
    return properties;
}
 
Example #3
Source File: JPATransactionManagerConfiguration.java    From high-performance-java-persistence with Apache License 2.0 6 votes vote down vote up
protected Properties additionalProperties() {
    Properties properties = new Properties();
    properties.setProperty("hibernate.dialect", hibernateDialect);
    properties.setProperty("hibernate.hbm2ddl.auto", "create-drop");
    properties.put(
        "hibernate.session_factory.statement_inspector",
        new LoggingStatementInspector("com.vladmihalcea.book.hpjp.hibernate.transaction")
    );
    properties.put(
        "hibernate.integrator_provider",
            (IntegratorProvider) () -> Collections.singletonList(
                new ClassImportIntegrator(Arrays.asList(PostDTO.class))
            )
    );
    return properties;
}
 
Example #4
Source File: JTATransactionManagerConfiguration.java    From high-performance-java-persistence with Apache License 2.0 6 votes vote down vote up
protected Properties additionalProperties() {
    Properties properties = new Properties();
    properties.setProperty("hibernate.transaction.jta.platform", BitronixJtaPlatform.class.getName());
    properties.setProperty("hibernate.dialect", hibernateDialect);
    properties.setProperty("hibernate.hbm2ddl.auto", "create-drop");
    properties.put(
        "hibernate.session_factory.statement_inspector",
        new LoggingStatementInspector("com.vladmihalcea.book.hpjp.hibernate.transaction")
    );
    properties.put(
        "hibernate.integrator_provider",
        (IntegratorProvider) () -> Collections.singletonList(
            new ClassImportIntegrator(Arrays.asList(PostDTO.class))
        )
    );
    return properties;
}
 
Example #5
Source File: AbstractJPAProgrammaticBootstrapTest.java    From high-performance-java-persistence with Apache License 2.0 6 votes vote down vote up
@Before
public void init() {
    PersistenceUnitInfo persistenceUnitInfo = persistenceUnitInfo(getClass().getSimpleName());

    Map<String, Object> configuration = new HashMap<>();

    Integrator integrator = integrator();
    if (integrator != null) {
        configuration.put("hibernate.integrator_provider", (IntegratorProvider) () -> Collections.singletonList(integrator));
    }

    emf = new HibernatePersistenceProvider().createContainerEntityManagerFactory(
        persistenceUnitInfo,
        configuration
    );
}
 
Example #6
Source File: AbstractTest.java    From high-performance-java-persistence with Apache License 2.0 6 votes vote down vote up
protected EntityManagerFactory newEntityManagerFactory() {
    PersistenceUnitInfo persistenceUnitInfo = persistenceUnitInfo(getClass().getSimpleName());
    Map configuration = properties();
    Interceptor interceptor = interceptor();
    if (interceptor != null) {
        configuration.put(AvailableSettings.INTERCEPTOR, interceptor);
    }
    Integrator integrator = integrator();
    if (integrator != null) {
        configuration.put("hibernate.integrator_provider", (IntegratorProvider) () -> Collections.singletonList(integrator));
    }

    EntityManagerFactoryBuilderImpl entityManagerFactoryBuilder = new EntityManagerFactoryBuilderImpl(
        new PersistenceUnitInfoDescriptor(persistenceUnitInfo), configuration
    );
    return entityManagerFactoryBuilder.build();
}
 
Example #7
Source File: AbstractTest.java    From hibernate-types with Apache License 2.0 5 votes vote down vote up
protected EntityManagerFactory newEntityManagerFactory() {
    PersistenceUnitInfo persistenceUnitInfo = persistenceUnitInfo(getClass().getSimpleName());
    Map<String, Object> configuration = new HashMap<>();
    configuration.put(AvailableSettings.INTERCEPTOR, interceptor());
    Integrator integrator = integrator();
    if (integrator != null) {
        configuration.put("hibernate.integrator_provider", (IntegratorProvider) () -> Collections.singletonList(integrator));
    }

    final List<Type> additionalTypes = additionalTypes();
    if (additionalTypes != null) {
        configuration.put("hibernate.type_contributors", (TypeContributorList) () -> {
            List<TypeContributor> typeContributors = new ArrayList<>();

            for (Type additionalType : additionalTypes) {
                if (additionalType instanceof BasicType) {
                    typeContributors.add((typeContributions, serviceRegistry) -> typeContributions.contributeType((BasicType) additionalType));


                } else if (additionalType instanceof UserType) {
                    typeContributors.add((typeContributions, serviceRegistry) -> typeContributions.contributeType((UserType) additionalType));
                } else if (additionalType instanceof CompositeUserType) {
                    typeContributors.add((typeContributions, serviceRegistry) -> typeContributions.contributeType((CompositeUserType) additionalType));
                }
            }
            return typeContributors;
        });
    }

    EntityManagerFactoryBuilderImpl entityManagerFactoryBuilder = new EntityManagerFactoryBuilderImpl(
            new PersistenceUnitInfoDescriptor(persistenceUnitInfo), configuration
    );
    return entityManagerFactoryBuilder.build();
}
 
Example #8
Source File: JPADTOProjectionClassImportIntegratorPropertyObjectExcludePathTest.java    From high-performance-java-persistence with Apache License 2.0 5 votes vote down vote up
@Override
protected void additionalProperties(Properties properties) {
    properties.put(
        "hibernate.integrator_provider",
        (IntegratorProvider) () -> List.of(
            new ClassImportIntegrator(
                List.of(
                    PostDTO.class
                )
            )
            .excludePath("com.vladmihalcea.book.hpjp.hibernate")
        )
    );
}
 
Example #9
Source File: JPADTOProjectionClassImportIntegratorPropertyObjectTest.java    From high-performance-java-persistence with Apache License 2.0 5 votes vote down vote up
@Override
protected void additionalProperties(Properties properties) {
    properties.put(
        "hibernate.integrator_provider",
        (IntegratorProvider) () -> List.of(
            new ClassImportIntegrator(
                List.of(PostDTO.class)
            )
        )
    );
}
 
Example #10
Source File: JPADTOProjectionTest.java    From high-performance-java-persistence with Apache License 2.0 5 votes vote down vote up
@Override
protected void additionalProperties(Properties properties) {
    properties.put(
        "hibernate.integrator_provider",
        (IntegratorProvider) () -> Collections.singletonList(
            new ClassImportIntegrator(
                Collections.singletonList(PostDTO.class)
            )
        )
    );
}
 
Example #11
Source File: ProjectionTest.java    From high-performance-java-persistence with Apache License 2.0 5 votes vote down vote up
@Override
protected void additionalProperties(Properties properties) {
    properties.put(
        "hibernate.integrator_provider",
        (IntegratorProvider) () -> Collections.singletonList(
            new ClassImportIntegrator(Collections.singletonList(PostCommentSummary.class))
        )
    );
}
 
Example #12
Source File: HibernateConfig.java    From tutorials with MIT License 4 votes vote down vote up
@Override
public void customize(Map<String, Object> hibernateProperties) {
    hibernateProperties.put("hibernate.integrator_provider", (IntegratorProvider) () -> Collections.singletonList(MetadataExtractorIntegrator.INSTANCE));
}