Java Code Examples for org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean

The following examples show how to use org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean. 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: txle   Source File: SecondaryConfig.java    License: Apache License 2.0 6 votes vote down vote up
@Bean(name = "secondaryEntityManagerFactory")
public LocalContainerEntityManagerFactoryBean entityManagerFactory(@Qualifier("secondaryDataSource") DataSource secondaryDataSource, EntityManagerFactoryBuilder builder) {
    return builder.dataSource(secondaryDataSource)
            .properties(jpaProperties.getProperties())
            .packages("com.actionsky.txle.grpc.entity")
            .persistenceUnit("secondaryPersistenceUnit")
            .build();
}
 
Example 2
@Bean
@DependsOn(value = {"simpleApplicationContextHolder"})
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    final LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();
    factoryBean.setDataSource(dataSource);
    factoryBean.setSharedCacheMode(SharedCacheMode.ENABLE_SELECTIVE);
    factoryBean.setValidationMode(ValidationMode.CALLBACK);
    factoryBean.setJpaVendorAdapter(jpaVendorAdapter);
    factoryBean.setPackagesToScan("com.devicehive.model");

    final Properties props = new Properties();
    props.putAll(this.properties.getHibernateProperties(this.dataSource));
    if (useNativeClient) {
        props.put("hibernate.cache.hazelcast.native_client_group", groupName);
        props.put("hibernate.cache.hazelcast.native_client_password", groupPassword);
        if (!CollectionUtils.isEmpty(clusterMembers)) {
            props.put("hibernate.cache.hazelcast.native_client_address", clusterMembers.get(0));
        }
    }

    factoryBean.setJpaProperties(props);
    return factoryBean;
}
 
Example 3
Source Project: Spring-Framework-Essentials   Source File: AppConfig.java    License: MIT License 6 votes vote down vote up
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(
        DataSource dataSource, JpaVendorAdapter jpaVendorAdapter) {

    Properties props = new Properties();
    props.setProperty("hibernate.format_sql", String.valueOf(true));

    LocalContainerEntityManagerFactoryBean emf =
            new LocalContainerEntityManagerFactoryBean();
    emf.setDataSource(dataSource);
    emf.setPackagesToScan("com.oreilly.entities");
    emf.setJpaVendorAdapter(jpaVendorAdapter);
    emf.setJpaProperties(props);

    return emf;
}
 
Example 4
@Bean
public EntityManagerFactory entityManagerFactory() {
    //  final Database database = Database.valueOf(vendor.toUpperCase());

    final LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setPersistenceUnitName("CCRI_PERSISTENCE_UNIT");
    // factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan("uk.nhs.careconnect.ri.database.entity");
    factory.setDataSource(dataSource());
    factory.setPersistenceProvider(new HibernatePersistenceProvider());
    factory.setJpaProperties(jpaProperties());
    factory.afterPropertiesSet();


    return factory.getObject();
}
 
Example 5
Source Project: multitenancy   Source File: MultiTenancyJpaConfiguration.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * org.springframework.beans.factory.FactoryBean that creates a JPA
 * {@link javax.persistence.EntityManagerFactory} according to JPA's standard
 * container bootstrap contract. This is the most powerful way to set up a
 * shared JPA EntityManagerFactory in a Spring application context; the
 * EntityManagerFactory can then be passed to JPA-based DAOs via dependency
 * injection. Note that switching to a JNDI lookup or to a
 * {@link org.springframework.orm.jpa.LocalEntityManagerFactoryBean} definition
 * is just a matter of configuration!
 * 
 * @param multiTenantConnectionProvider
 * @param currentTenantIdentifierResolver
 * @return
 */
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean(
        MultiTenantConnectionProvider multiTenantConnectionProvider,
        CurrentTenantIdentifierResolver currentTenantIdentifierResolver) {

    Map<String, Object> hibernateProps = new LinkedHashMap<>();
    hibernateProps.putAll(this.jpaProperties.getProperties());
    hibernateProps.put(Environment.MULTI_TENANT, MultiTenancyStrategy.DATABASE);
    hibernateProps.put(Environment.MULTI_TENANT_CONNECTION_PROVIDER, multiTenantConnectionProvider);
    hibernateProps.put(Environment.MULTI_TENANT_IDENTIFIER_RESOLVER, currentTenantIdentifierResolver);

    // No dataSource is set to resulting entityManagerFactoryBean
    LocalContainerEntityManagerFactoryBean result = new LocalContainerEntityManagerFactoryBean();
    result.setPackagesToScan(new String[] { Employee.class.getPackage().getName() });
    result.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
    result.setJpaPropertyMap(hibernateProps);

    return result;
}
 
Example 6
Source Project: app-engine   Source File: TaskDbConfig.java    License: Apache License 2.0 6 votes vote down vote up
@Bean
LocalContainerEntityManagerFactoryBean taskEntityManagerFactory() {

    HibernateJpaVendorAdapter jpaVendorAdapter = new HibernateJpaVendorAdapter();
    jpaVendorAdapter.setGenerateDdl(true);

    LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();

    factoryBean.setDataSource(dataSource);
    factoryBean.setJpaVendorAdapter(jpaVendorAdapter);
    //此处应包含当前模块的domain类
    String packageName = TaskDbConfig.class.getPackage().getName();
    factoryBean.setPackagesToScan(StringUtils.substring(packageName, 0, StringUtils.lastIndexOf(packageName, '.')));

    return factoryBean;
}
 
Example 7
Source Project: bearchoke   Source File: JpaCoreConfig.java    License: Apache License 2.0 6 votes vote down vote up
@Bean
public EntityManagerFactory entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean lef = new LocalContainerEntityManagerFactoryBean();
    lef.setDataSource(dataSource);
    lef.setJpaVendorAdapter(jpaVendorAdapter());
    String[] packages = environment.getProperty("jpa.packages.to.scan").split(",");
    lef.setPackagesToScan(packages);

    Properties props = new Properties();
    props.put("hibernate.show_sql", "true");
    props.put("hibernate.format_sql", "true");
    props.put("hibernate.ejb.naming_strategy", "org.hibernate.cfg.ImprovedNamingStrategy");
    props.put("hibernate.connection.charSet", "UTF-8");
    props.put("hibernate.current_session_context_class", "jta");
    props.put("hibernate.archive.autodetection", "class");
    props.put("hibernate.transaction.manager_lookup_class", "com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup");
    props.put("hibernate.dialect", environment.getProperty("jpa.dialect"));
    props.put("hibernate.hbm2ddl.auto", environment.getProperty("jpa.hibernate.create.strategy"));
    lef.setJpaProperties(props);

    lef.afterPropertiesSet();

    return lef.getObject();
}
 
Example 8
@Override
public EntityManagerFactory createTempEntityManagerFactory(
		Organization organization) {
	SingleConnectionDataSource dataSource = dataSourceService.createSingleConnectionDataSource(organization);
	if (dataSource != null) {
		Map<String, Object> vendorProperties = getVendorProperties(dataSource);
		customizeVendorProperties(vendorProperties);
	    Builder builder = getEntityManagerFactoryBuilder(dataSource).dataSource(dataSource).packages(mergePackagesToScan())
				.properties(vendorProperties).jta(isJta());
		LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = builder.build();
		entityManagerFactoryBean.setBeanClassLoader(classLoader);
		entityManagerFactoryBean.setBeanFactory(beanFactory);
		entityManagerFactoryBean.setBeanName(beanName);
		entityManagerFactoryBean.setLoadTimeWeaver(loadTimeWeaver);
		entityManagerFactoryBean.setResourceLoader(resourceLoader);
		entityManagerFactoryBean.afterPropertiesSet();
		return entityManagerFactoryBean.getObject();
	}
	return null;
}
 
Example 9
Source Project: we-cmdb   Source File: DatabaseConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource, JpaVendorAdapter jpaVendorAdapter) {
    LocalContainerEntityManagerFactoryBean emfb = new LocalContainerEntityManagerFactoryBean();
    emfb.setDataSource(dataSource);
    emfb.setJpaVendorAdapter(jpaVendorAdapter);
    emfb.setPackagesToScan("com.webank.cmdb.domain");
    emfb.setJpaPropertyMap(getCustomizedProperties());
    return emfb;
}
 
Example 10
Source Project: rqueue   Source File: BaseApplication.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
  HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
  vendorAdapter.setGenerateDdl(true);
  LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
  factory.setJpaVendorAdapter(vendorAdapter);
  factory.setPackagesToScan("com.github.sonus21.rqueue.test.entity");
  factory.setDataSource(dataSource());
  return factory;
}
 
Example 11
@Bean @DependsOn("flyway")
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean localContainerEntityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
    localContainerEntityManagerFactoryBean.setPersistenceUnitName(getClass().getSimpleName());
    localContainerEntityManagerFactoryBean.setPersistenceProvider(new HibernatePersistenceProvider());
    localContainerEntityManagerFactoryBean.setDataSource(dataSource());
    localContainerEntityManagerFactoryBean.setPackagesToScan(packagesToScan());

    JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    localContainerEntityManagerFactoryBean.setJpaVendorAdapter(vendorAdapter);
    localContainerEntityManagerFactoryBean.setJpaProperties(additionalProperties());
    return localContainerEntityManagerFactoryBean;
}
 
Example 12
Source Project: spring4-sandbox   Source File: DataEnversConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
	LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
	emf.setDataSource(dataSource());
	emf.setPackagesToScan("com.hantsylabs.example.spring.model");
	emf.setPersistenceProvider(new HibernatePersistenceProvider());
	emf.setJpaProperties(jpaProperties());
	return emf;
}
 
Example 13
Source Project: javers   Source File: JaversSpringJpaApplicationConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource());
    em.setPackagesToScan("org.javers.spring.model");

    JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    em.setJpaVendorAdapter(vendorAdapter);
    em.setJpaProperties(additionalProperties());

    return em;
}
 
Example 14
Source Project: spring-content   Source File: ElasticsearchConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setDatabase(Database.H2);
    vendorAdapter.setGenerateDdl(true);

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan("org.springframework.content.elasticsearch");
    factory.setDataSource(dataSource());

    return factory;
}
 
Example 15
@Bean(name = "cardEntityManagerFactory")
public LocalContainerEntityManagerFactoryBean cardEntityManagerFactory(
        EntityManagerFactoryBuilder builder) {
    return builder
            .dataSource(cardDataSource())
            .packages(Card.class)
            .build();
}
 
Example 16
@Primary
@Bean(name = "memberEntityManagerFactory")
public LocalContainerEntityManagerFactoryBean memberEntityManagerFactory(EntityManagerFactoryBuilder builder) {
    return builder
            .dataSource(memberDataSource())
            .packages(Member.class)
            .build();
}
 
Example 17
Source Project: tutorials   Source File: H2JpaConfig.java    License: MIT License 5 votes vote down vote up
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource());
    em.setPackagesToScan(new String[] { "com.baeldung.boot.domain", "com.baeldung.boot.model", "com.baeldung.boot.boottest", "com.baeldung.model" });
    em.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
    em.setJpaProperties(additionalProperties());
    return em;
}
 
Example 18
Source Project: tutorials   Source File: PersistenceProductAutoConfiguration.java    License: MIT License 5 votes vote down vote up
@Bean
public LocalContainerEntityManagerFactoryBean productEntityManager() {
    final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(productDataSource());
    em.setPackagesToScan("com.baeldung.multipledb.model.product");

    final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    em.setJpaVendorAdapter(vendorAdapter);
    final HashMap<String, Object> properties = new HashMap<String, Object>();
    properties.put("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto"));
    properties.put("hibernate.dialect", env.getProperty("hibernate.dialect"));
    em.setJpaPropertyMap(properties);

    return em;
}
 
Example 19
Source Project: spring4-sandbox   Source File: JpaConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
	LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
	emf.setDataSource(dataSource());
	emf.setPackagesToScan("com.hantsylabs.example.spring.model");
	emf.setPersistenceProvider(new HibernatePersistenceProvider());
	emf.setJpaProperties(jpaProperties());
	return emf;
}
 
Example 20
Source Project: tutorials   Source File: AppConfig.java    License: MIT License 5 votes vote down vote up
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource());
    em.setPackagesToScan(new String[] { "com.baeldung.relationships.models" });
    em.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
    em.setJpaProperties(additionalProperties());
    return em;
}
 
Example 21
Source Project: tenancy-sample   Source File: TenancySampleApplication.java    License: Apache License 2.0 5 votes vote down vote up
public
@Bean
EntityManagerFactory customEntityManagerFactory(DataSource dataSource) {
    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setGenerateDdl(false); // turn off with Discriminator strategy so far!
    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan(TenancySampleApplication.class.getPackage().getName());
    factory.setDataSource(dataSource);
    factory.getJpaPropertyMap().put(Environment.DIALECT, PostgreSQL9Dialect.class.getName());
    factory.getJpaPropertyMap().put(Environment.MULTI_TENANT, MultiTenancyStrategy.DISCRIMINATOR);
    factory.getJpaPropertyMap().put(Environment.MULTI_TENANT_IDENTIFIER_RESOLVER, new TenantHolder());
    factory.afterPropertiesSet();
    return factory.getObject();
}
 
Example 22
Source Project: java-platform   Source File: RepositoryConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
	public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
		LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();

		HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
		vendorAdapter.setGenerateDdl(Boolean.TRUE);
		vendorAdapter.setShowSql(Boolean.TRUE);

		factory.setDataSource(dataSource());
		factory.setJpaVendorAdapter(vendorAdapter);
		factory.setPackagesToScan("com.whenling");
		factory.setJpaDialect(new HibernateJpaDialect());

		Properties jpaProperties = new Properties();
		jpaProperties.put("hibernate.id.new_generator_mappings", false);
		jpaProperties.put("hibernate.hbm2ddl.auto", hibernateHbm2ddlAuto);
		jpaProperties.put("hibernate.dialect", hibernateDialect);
		jpaProperties.put("hibernate.show_sql", hibernateShowSql);
		jpaProperties.put("hibernate.format_sql", hibernateFormatSql);
		jpaProperties.put("hibernate.current_session_context_class", hibernateCurrentSessionContextClass);

		jpaProperties.put("javax.persistence.validation.mode", javaxPersistenceValidationMode);
		jpaProperties.put("hibernate.query.substitutions", hibernateQuerySubstitutions);
		jpaProperties.put("hibernate.default_batch_fetch_size", hibernateDefaultBatchFetchSize);
		jpaProperties.put("hibernate.max_fetch_depth", hibernateMaxFetchDepth);
		jpaProperties.put("hibernate.enable_lazy_load_no_trans", hibernateEnableLazyLoadNoTrans);
		jpaProperties.put("hibernate.bytecode.use_reflection_optimizer", hibernateBytecodeUseReflectionOptimizer);

		jpaProperties.put("hibernate.cache.use_second_level_cache", hibernateCacheUseSecondLevelCache);
		jpaProperties.put("hibernate.cache.region.factory_class", hibernateCacheInfinispanRegionFactoryClass);
//		jpaProperties.put("hibernate.cache.infinispan.cfg", hibernateCacheInfinispanCfg);
		jpaProperties.put("javax.persistence.sharedCache.mode", javaxPersistenceSharedCacheMode);
		jpaProperties.put("hibernate.generate_statistics", hibernateGenerateStatistics);

		jpaProperties.put("hibernate.cache.use_query_cache", hibernateCacheUseQueryCache);
		factory.setJpaProperties(jpaProperties);

		return factory;
	}
 
Example 23
Source Project: Project   Source File: JpaConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource, JpaVendorAdapter jpaVendorAdapter) {
  LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
  emf.setDataSource(dataSource);
  emf.setPersistenceUnitName("spittr");
  emf.setJpaVendorAdapter(jpaVendorAdapter);
  emf.setPackagesToScan("spittr.domain");
  return emf;
}
 
Example 24
Source Project: blog-examples   Source File: Application.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public EntityManagerFactory entityManagerFactory() throws SQLException {
	HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
	vendorAdapter.setGenerateDdl(true);
	LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
	factory.setJpaVendorAdapter(vendorAdapter);
	factory.setPackagesToScan("com.mscharhag.springjooq.entity");
	factory.setDataSource(dataSource());
	factory.afterPropertiesSet();
	return factory.getObject();
}
 
Example 25
Source Project: logging-log4j-audit   Source File: HibernateConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public EntityManagerFactory entityManagerFactory() {
    AbstractJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setGenerateDdl(false);

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan("org.apache.logging.log4j.catalog");
    factory.setDataSource(dataSourceConfig.dataSource());
    factory.afterPropertiesSet();

    return factory.getObject();
}
 
Example 26
Source Project: jwala   Source File: AemJpaConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public LocalContainerEntityManagerFactoryBean getEntityManagerFactoryBean(final DataSource dataSource) {

    final LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setDataSource(dataSource);
    factory.setJpaVendorAdapter(new OpenJpaVendorAdapter());
    factory.setPersistenceUnitName("jwala-unit");
    factory.setPersistenceXmlLocation("classpath:META-INF/persistence.xml");

    return factory;
}
 
Example 27
Source Project: spring-cloud   Source File: RepositorySecondaryConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean(destroyMethod = "", name = "entityManagerFactorySecondary")
public LocalContainerEntityManagerFactoryBean entityManagerFactorySecondary(EntityManagerFactoryBuilder builder) {
    return builder.dataSource(w_ds)
            .properties(getVendorProperties(w_ds))
            .packages("cn.cib.entity.write")
            .persistenceUnit("secondaryPersistenceUnit").build();
}
 
Example 28
Source Project: score   Source File: PartitionTemplateWithEmfTest.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
@DependsOn("liquibase")
LocalContainerEntityManagerFactoryBean entityManagerFactory(JpaVendorAdapter jpaVendorAdapter) {
    LocalContainerEntityManagerFactoryBean fb = new LocalContainerEntityManagerFactoryBean();
    fb.setDataSource(dataSource());
    fb.setPersistenceProviderClass(HibernatePersistenceProvider.class);
    fb.setPackagesToScan("io.cloudslang.engine.partitions");
    fb.setJpaVendorAdapter(jpaVendorAdapter);
    return fb;
}
 
Example 29
Source Project: market   Source File: DataConfig.java    License: MIT License 5 votes vote down vote up
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource) {
	LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); // todo: EntityManagerFactoryBuilder ?
	em.setDataSource(dataSource);
	em.setPackagesToScan("market.domain");
	em.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
	return em;
}
 
Example 30
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean localContainerEntityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
    localContainerEntityManagerFactoryBean.setPersistenceUnitName(getClass().getSimpleName());
    localContainerEntityManagerFactoryBean.setPersistenceProvider(new HibernatePersistenceProvider());
    localContainerEntityManagerFactoryBean.setDataSource(dataSource());
    localContainerEntityManagerFactoryBean.setPackagesToScan(packagesToScan());

    JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    localContainerEntityManagerFactoryBean.setJpaVendorAdapter(vendorAdapter);
    localContainerEntityManagerFactoryBean.setJpaProperties(additionalProperties());
    return localContainerEntityManagerFactoryBean;
}