org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter Java Examples

The following examples show how to use org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter. 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: JPAConfiguration.java    From ariADDna with Apache License 2.0 7 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.stnetix.ariaddna.persistence.entities");
    factory.setDataSource(dataSource());
    Properties properties = new Properties();
    properties.put("hibernate.default_schema", "public");
    properties.put("hibernate.hbm2ddl.auto", "create-drop");
    properties.put("hibernate.show_sql", "true");
    properties.put("hibernate.format_sql", "true");
    properties.put("hibernate.use_sql_comments", "true");
    properties.put("hibernate.temp.use_jdbc_metadata_defaults", "false");
    properties.put("hibernate.dialect", dialect);

    factory.setJpaProperties(properties);
    factory.afterPropertiesSet();

    return factory.getObject();
}
 
Example #2
Source File: MultiTenancyJpaConfiguration.java    From multitenancy with 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 #3
Source File: Utils.java    From radman with MIT License 6 votes vote down vote up
static LocalContainerEntityManagerFactoryBean buildEntityManager(DataSource dataSource,
                                                                 JpaProperties jpaProperties,
                                                                 String entitiesPackage,
                                                                 String persistenceUnitName) {
    LocalContainerEntityManagerFactoryBean entityManager = new LocalContainerEntityManagerFactoryBean();
    entityManager.setDataSource(dataSource);
    entityManager.setPackagesToScan(entitiesPackage);
    entityManager.setPersistenceUnitName(persistenceUnitName);
    entityManager.setJpaVendorAdapter(new HibernateJpaVendorAdapter());

    HashMap<String, Object> properties = new HashMap<>();
    properties.put("hibernate.hbm2ddl.auto", jpaProperties.getHibernate().getDdlAuto());
    properties.put("hibernate.dialect", jpaProperties.getHibernate().getDialect());
    properties.put("show-sql", jpaProperties.getShowSql());

    entityManager.setJpaPropertyMap(properties);
    return entityManager;
}
 
Example #4
Source File: JpaInfrastructureConfig.java    From spring-content with Apache License 2.0 6 votes vote down vote up
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {

	HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
	vendorAdapter.setDatabase(Database.HSQL);
	vendorAdapter.setGenerateDdl(true);

	LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
	factory.setJpaVendorAdapter(vendorAdapter);
	factory.setPackagesToScan(packagesToScan());
	factory.setPersistenceUnitName("spring-data-rest-webmvc");
	factory.setDataSource(dataSource());
	factory.afterPropertiesSet();

	return factory;
}
 
Example #5
Source File: DataConfig.java    From pizzeria with MIT License 6 votes vote down vote up
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setShowSql(true);

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setDataSource(dataSource());
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan("pzinsta.pizzeria.model");
    factory.setJpaPropertyMap(
            ImmutableMap.of(
                    "hibernate.dialect", environment.getProperty("hibernate.dialect"),
                    "hibernate.hbm2ddl.auto", environment.getProperty("hibernate.hbm2ddl.auto"),
                    "hibernate.hbm2ddl.import_files_sql_extractor", environment.getProperty("hibernate.hbm2ddl.import_files_sql_extractor"),
                    "hibernate.hbm2ddl.import_files", environment.getProperty("hibernate.hbm2ddl.import_files")
            ));
    return factory;
}
 
Example #6
Source File: PersistenceUserAutoConfiguration.java    From tutorials with MIT License 6 votes vote down vote up
@Primary
@Bean
public LocalContainerEntityManagerFactoryBean userEntityManager() {
    final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(userDataSource());
    em.setPackagesToScan("com.baeldung.multipledb.model.user");

    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 #7
Source File: InventoryConfig.java    From tutorials with MIT License 6 votes vote down vote up
@Bean
public EntityManagerFactory inventoryEntityManager() {
    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan("com.baeldung.atomikos.spring.jpa.inventory");
    factory.setDataSource(inventoryDataSource());
    Properties jpaProperties = new Properties();
    //jpaProperties.put("hibernate.show_sql", "true");
    //jpaProperties.put("hibernate.format_sql", "true");
    jpaProperties.put("hibernate.dialect", "org.hibernate.dialect.DerbyDialect");
    jpaProperties.put("hibernate.current_session_context_class", "jta");
    jpaProperties.put("javax.persistence.transactionType", "jta");
    jpaProperties.put("hibernate.transaction.manager_lookup_class", "com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup");
    jpaProperties.put("hibernate.hbm2ddl.auto", "create-drop");
    factory.setJpaProperties(jpaProperties);
    factory.afterPropertiesSet();
    return factory.getObject();
}
 
Example #8
Source File: TaskDbConfig.java    From app-engine with 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 #9
Source File: PersistenceUserConfiguration.java    From tutorials with MIT License 6 votes vote down vote up
@Primary
@Bean
public LocalContainerEntityManagerFactoryBean userEntityManager() {
    System.out.println("loading config");
    final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(userDataSource());
    em.setPackagesToScan("com.baeldung.multipledb.model.user");

    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 #10
Source File: OrderConfig.java    From tutorials with MIT License 6 votes vote down vote up
@Bean
public EntityManagerFactory orderEntityManager() {
    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan("com.baeldung.atomikos.spring.jpa.order");
    factory.setDataSource(orderDataSource());
    Properties jpaProperties = new Properties();
    //jpaProperties.put("hibernate.show_sql", "true");
    //jpaProperties.put("hibernate.format_sql", "true");
    jpaProperties.put("hibernate.dialect", "org.hibernate.dialect.DerbyDialect");
    jpaProperties.put("hibernate.current_session_context_class", "jta");
    jpaProperties.put("javax.persistence.transactionType", "jta");
    jpaProperties.put("hibernate.transaction.manager_lookup_class", "com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup");
    jpaProperties.put("hibernate.hbm2ddl.auto", "create-drop");
    factory.setJpaProperties(jpaProperties);
    factory.afterPropertiesSet();
    return factory.getObject();
}
 
Example #11
Source File: ReplicationDataSourceApplicationConfig.java    From replication-datasource with Apache License 2.0 5 votes vote down vote up
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(@Qualifier("dataSource") DataSource dataSource) {
    LocalContainerEntityManagerFactoryBean emfb = new LocalContainerEntityManagerFactoryBean();
    emfb.setDataSource(dataSource);
    emfb.setPersistenceUnitName("replicationTest");
    JpaVendorAdapter jpaVendorAdapter = new HibernateJpaVendorAdapter();
    emfb.setJpaVendorAdapter(jpaVendorAdapter);
    return emfb;
}
 
Example #12
Source File: MainConfig.java    From spring-boot-jta-atomikos-sample with Apache License 2.0 5 votes vote down vote up
@Bean
public JpaVendorAdapter jpaVendorAdapter() {
	HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter();
	hibernateJpaVendorAdapter.setShowSql(true);
	hibernateJpaVendorAdapter.setGenerateDdl(true);
	hibernateJpaVendorAdapter.setDatabase(Database.MYSQL);
	return hibernateJpaVendorAdapter;
}
 
Example #13
Source File: ReplicationDataSourceApplicationConfig.java    From replication-datasource with Apache License 2.0 5 votes vote down vote up
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(@Qualifier("dataSource") DataSource dataSource) {
    LocalContainerEntityManagerFactoryBean emfb = new LocalContainerEntityManagerFactoryBean();
    emfb.setDataSource(dataSource);
    emfb.setPersistenceUnitName("replicationTest");
    JpaVendorAdapter jpaVendorAdapter = new HibernateJpaVendorAdapter();
    emfb.setJpaVendorAdapter(jpaVendorAdapter);
    return emfb;
}
 
Example #14
Source File: PersistenceTestConfig.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    final LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
    emf.setDataSource(restDataSource());
    emf.setPackagesToScan(new String[] { "com.baeldung.persistence.model" });

    final JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    emf.setJpaVendorAdapter(vendorAdapter);
    emf.setJpaProperties(hibernateProperties());

    return emf;
}
 
Example #15
Source File: DataConfig.java    From market with 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 #16
Source File: MySQLAutoconfiguration.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
@ConditionalOnBean(name = "dataSource")
LocalContainerEntityManagerFactoryBean entityManagerFactory() throws IOException {
  final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
  em.setDataSource(dataSource());
  em.setPackagesToScan(new String[] { "com.baeldung.persistence.model" });
 
  final JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
  em.setJpaVendorAdapter(vendorAdapter);
  em.setJpaProperties(additionalProperties());
  return em;
}
 
Example #17
Source File: JaversSpringJpaApplicationConfig.java    From javers with 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 #18
Source File: EntityTestSupport.java    From ddd-java with MIT License 5 votes vote down vote up
protected void setupEntityManagerFactory() {
    DataSource ds = EntityTestFactory.dataSource();
    Map<String, String> props = new HashMap<>();
    props.put(AvailableSettings.HBM2DDL_AUTO, "create-drop");
    Builder builder = new EntityManagerFactoryBuilder(new HibernateJpaVendorAdapter(), props, null)
            .dataSource(ds)
            .jta(false);
    if (!targetEntities.isEmpty()) {
        builder.packages(targetEntities.toArray(new Class<?>[0]));
    }
    LocalContainerEntityManagerFactoryBean emfBean = builder.build();
    emfBean.afterPropertiesSet();
    emf = emfBean.getObject();
    txm = new JpaTransactionManager(emf);
}
 
Example #19
Source File: JpaConfiguration.java    From ps-guitar-db with Apache License 2.0 5 votes vote down vote up
@Bean
public JpaVendorAdapter jpaVendorAdapter() {
	HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter();
	hibernateJpaVendorAdapter.setShowSql(true);
	hibernateJpaVendorAdapter.setGenerateDdl(true);
	hibernateJpaVendorAdapter.setDatabase(Database.H2);
	return hibernateJpaVendorAdapter;
}
 
Example #20
Source File: EngineTest.java    From score with Apache License 2.0 5 votes vote down vote up
@Bean
JpaVendorAdapter jpaVendorAdapter() {
    HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
    adapter.setShowSql(false);
    adapter.setGenerateDdl(true);
    return adapter;
}
 
Example #21
Source File: DataRepositoryConfiguration.java    From spring-data-jpa-entity-graph with MIT License 5 votes vote down vote up
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {

  LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
  factory.setDataSource(dataSource());
  factory.setMappingResources("META-INF/orm.xml");
  factory.setPackagesToScan("com.cosium.spring.data.jpa.entity.graph");

  HibernateJpaVendorAdapter jpaVendorAdapter = new HibernateJpaVendorAdapter();
  jpaVendorAdapter.setDatabase(Database.H2);
  jpaVendorAdapter.setGenerateDdl(true);
  factory.setJpaVendorAdapter(jpaVendorAdapter);

  return factory;
}
 
Example #22
Source File: AbstractJpaConfiguration.java    From abixen-platform with GNU Lesser General Public License v2.1 5 votes vote down vote up
private JpaVendorAdapter jpaVendorAdapter() {

        HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
        vendorAdapter.setGenerateDdl(false);
        vendorAdapter.setShowSql(false);
        return vendorAdapter;
    }
 
Example #23
Source File: PersistenceJPAConfig.java    From hibernate-postgresql with Apache License 2.0 5 votes vote down vote up
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource());
    em.setPackagesToScan(new String[] { Marker.class.getPackage().getName() });

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

    return em;
}
 
Example #24
Source File: DatabaseConfiguration.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Bean(name = "entityManagerFactory")
public EntityManagerFactory entityManagerFactory(DataSource dataSource) {
    LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
    entityManagerFactoryBean.setDataSource(dataSource);
    entityManagerFactoryBean.setPackagesToScan("org.flowable.rest.api.jpa.model");
    entityManagerFactoryBean.setPersistenceUnitName("test");
    HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter();
    hibernateJpaVendorAdapter.setShowSql(false);
    hibernateJpaVendorAdapter.setGenerateDdl(true);
    hibernateJpaVendorAdapter.setDatabase(Database.H2);
    entityManagerFactoryBean.setJpaVendorAdapter(hibernateJpaVendorAdapter);
    entityManagerFactoryBean.afterPropertiesSet();
    return entityManagerFactoryBean.getObject();
}
 
Example #25
Source File: RepositoryConfiguration.java    From java-platform with 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 #26
Source File: Spring4Config.java    From JUnit-5-Quick-Start-Guide-and-Framework-Support with MIT License 5 votes vote down vote up
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource());
    em.setPackagesToScan("com.dmitrijdrandarov");

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

    return em;
}
 
Example #27
Source File: Spring5Config.java    From JUnit-5-Quick-Start-Guide-and-Framework-Support with MIT License 5 votes vote down vote up
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource());
    em.setPackagesToScan("com.dmitrijdrandarov");

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

    return em;
}
 
Example #28
Source File: PersistenceConfig.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    final LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
    emf.setDataSource(restDataSource());
    emf.setPackagesToScan("com.baeldung.persistence.model");

    final JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    emf.setJpaVendorAdapter(vendorAdapter);
    emf.setJpaProperties(hibernateProperties());

    return emf;
}
 
Example #29
Source File: EnableJpaStoresTest.java    From spring-content with Apache License 2.0 5 votes vote down vote up
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
	HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
	vendorAdapter.setDatabase(Database.HSQL);
	vendorAdapter.setGenerateDdl(true);

	LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
	factory.setJpaVendorAdapter(vendorAdapter);
	factory.setPackagesToScan(getClass().getPackage().getName());
	factory.setDataSource(dataSource());

	return factory;
}
 
Example #30
Source File: EnableCmisTest.java    From spring-content with 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.cmis.integration");
	factory.setDataSource(dataSource());

	return factory;
}