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

The following examples show how to use org.hibernate.jpa.boot.spi.IntegratorProvider. These examples are extracted from open source projects. 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 Project: hibernate-types   Source File: AbstractTest.java    License: 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
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
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
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
@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
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 Project: hibernate-types   Source File: AbstractTest.java    License: 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
@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
@Override
protected void additionalProperties(Properties properties) {
    properties.put(
        "hibernate.integrator_provider",
        (IntegratorProvider) () -> List.of(
            new ClassImportIntegrator(
                List.of(PostDTO.class)
            )
        )
    );
}
 
Example 10
@Override
protected void additionalProperties(Properties properties) {
    properties.put(
        "hibernate.integrator_provider",
        (IntegratorProvider) () -> Collections.singletonList(
            new ClassImportIntegrator(
                Collections.singletonList(PostDTO.class)
            )
        )
    );
}
 
Example 11
@Override
protected void additionalProperties(Properties properties) {
    properties.put(
        "hibernate.integrator_provider",
        (IntegratorProvider) () -> Collections.singletonList(
            new ClassImportIntegrator(Collections.singletonList(PostCommentSummary.class))
        )
    );
}
 
Example 12
Source Project: tutorials   Source File: HibernateConfig.java    License: 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));
}