@Bean(EntityManagerFactoryBeanName) @Primary public LocalContainerEntityManagerFactoryBean entityManagerFactory( @Qualifier(DataSourceBeanName) DataSource dataSource, @Qualifier(JpaVendorAdapterBeanName) JpaVendorAdapter vendorAdapter) { LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean(); entityManagerFactoryBean.setDataSource(dataSource); entityManagerFactoryBean.setJpaVendorAdapter(vendorAdapter); entityManagerFactoryBean.setJpaDialect(new HibernateJpaDialect()); entityManagerFactoryBean.setPackagesToScan(Organization.class.getPackage().getName()); entityManagerFactoryBean.setPersistenceUnitName("mysqlsource1"); entityManagerFactoryBean.afterPropertiesSet(); return entityManagerFactoryBean; }
@Bean(name = "coreEntityManager") public LocalContainerEntityManagerFactoryBean entityManagerFactory() { if (driver == null){ throw new IllegalStateException("cannot find db.type property with valid value ( mysql,ms-sql)"); } driver.create(); LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(driver.create()); em.setPackagesToScan(new String[]{"com"}); JpaVendorAdapter adapter = new HibernateJpaVendorAdapter(); HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); vendorAdapter.setShowSql(false); vendorAdapter.setGenerateDdl(false); em.setJpaVendorAdapter(vendorAdapter); em.setJpaProperties(additionalProperties()); return em; }
@Bean @ConditionalOnMissingBean public EntityManagerFactoryBuilder entityManagerFactoryBuilder( JpaVendorAdapter jpaVendorAdapter, ObjectProvider<PersistenceUnitManager> persistenceUnitManagerProvider) { EntityManagerFactoryBuilder builder = new EntityManagerFactoryBuilder( jpaVendorAdapter, this.properties.getProperties(), persistenceUnitManagerProvider.getIfAvailable()); builder.setCallback(getVendorCallback()); return builder; }
@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; }
@Bean(name = "entityManagerFactory") @DependsOn("flyway") @Profile("sqlDb") public LocalContainerEntityManagerFactoryBean serverEntityManagerFactory(DataSource dataSource, JpaVendorAdapter vendorAdapter, LoadTimeWeaver loadTimeWeaver, Properties hibernateProperties) { LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource); em.setJpaVendorAdapter(vendorAdapter); em.setLoadTimeWeaver(loadTimeWeaver); em.setJpaProperties(hibernateProperties); em.setPackagesToScan(ENTITIES_PACKAGE); return em; }
private EntityManagerFactory createEntityManagerFactory() { Assertions.assertThat(persistenceUnitContextManager.isValidPersistenceUnit(persistenceUnitName)) .as("Not a valid persistence unit: %s", persistenceUnitName) .isTrue(); final LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setPersistenceUnitManager(persistenceUnitManager); factory.setPersistenceUnitName(persistenceUnitName); final JpaVendorAdapter jpaVendorAdapter = getJpaVendorAdapter(); if (jpaVendorAdapter != null) { factory.setJpaVendorAdapter(jpaVendorAdapter); } else { factory.setPersistenceProvider(getPersistenceProvider()); } final JpaDialect jpaDialect = getJpaDialect(); if (jpaDialect != null) { factory.setJpaDialect(jpaDialect); } factory.afterPropertiesSet(); final String entityManagerFactoryBeanName = getPersistenceUnitName() + PersistenceProperties.ENTITY_MANAGER_FACTORY_NAME_SUFFIX; MergedContext.getInstance().registerBean(entityManagerFactoryBeanName, factory); Assertions.assertThat(MergedContext.getInstance().getBean(entityManagerFactoryBeanName)).isNotNull(); return factory.getObject(); }
/** * Gets the Hibernate JPA vendor adapter needed by the entity manager. * * @return the Hibernate JPA vendor adapter. */ private JpaVendorAdapter getHibernateJpaVendorAdapter() { HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter(); // Set the database type. String databaseType = configurationHelper.getProperty(ConfigurationValue.DATABASE_TYPE); if (StringUtils.isBlank(databaseType)) { throw new IllegalStateException( String.format("No database type found. Ensure the \"%s\" configuration entry is configured.", ConfigurationValue.DATABASE_TYPE.getKey())); } Database database = Database.valueOf(databaseType); LOGGER.info("jpaTargetDatabase={}", database); hibernateJpaVendorAdapter.setDatabase(database); hibernateJpaVendorAdapter.setGenerateDdl(false); return hibernateJpaVendorAdapter; }
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() { LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); JpaVendorAdapter jpaVendorAdapter = new HibernateJpaVendorAdapter(); DriverManagerDataSource dataSource = new DriverManagerDataSource(); dataSource.setUsername("root"); dataSource.setPassword(""); dataSource.setUrl("jdbc:mysql://localhost:3306/ensaiospring"); dataSource.setDriverClassName("com.mysql.jdbc.Driver"); Properties props = new Properties(); props.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect"); props.setProperty("hibernate.show_sql", "true"); props.setProperty("hibernate.hbm2ddl.auto", "update"); factory.setJpaVendorAdapter(jpaVendorAdapter); factory.setDataSource(dataSource); factory.setJpaProperties(props); factory.setPackagesToScan("br.com.ciaware.springmvc.ensaio.models"); return factory; }
public JpaConfigDataHolder(final JpaVendorAdapter jpaVendorAdapter, final String persistenceUnitName, final String[] packagesToScan, final DataSource dataSource) { this.jpaVendorAdapter = jpaVendorAdapter; this.persistenceUnitName = persistenceUnitName; this.packagesToScan = packagesToScan; this.dataSource = dataSource; }
@Bean public JpaVendorAdapter jpaVendorAdapter() { HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter(); hibernateJpaVendorAdapter.setShowSql(true); hibernateJpaVendorAdapter.setGenerateDdl(true); hibernateJpaVendorAdapter.setDatabase(Database.H2); return hibernateJpaVendorAdapter; }
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource, JpaVendorAdapter jpaVendorAdapter) { LocalContainerEntityManagerFactoryBean lef = new LocalContainerEntityManagerFactoryBean(); lef.setDataSource(dataSource); lef.setJpaVendorAdapter(jpaVendorAdapter); lef.setPackagesToScan("de.adesso.jenkinshue.entity"); lef.setJpaProperties(dataSourceConfig.getJpaProperties()); lef.afterPropertiesSet(); return lef; }
@Bean public JpaVendorAdapter jpaVendorAdapter() { HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter(); hibernateJpaVendorAdapter.setShowSql(sql); hibernateJpaVendorAdapter.setGenerateDdl(sql); hibernateJpaVendorAdapter.setDatabase(Database.POSTGRESQL); return hibernateJpaVendorAdapter; }
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() { LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource()); em.setPackagesToScan("org.restaurant.repository.model"); JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); em.setJpaVendorAdapter(vendorAdapter); em.setJpaProperties(additionalProperties()); return em; }
@Bean(EntityManagerFactoryBeanName) public LocalContainerEntityManagerFactoryBean entityManagerFactory( @Qualifier(DataSourceBeanName) DataSource dataSource, @Qualifier(JpaVendorAdapterBeanName) JpaVendorAdapter vendorAdapter) { LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean(); entityManagerFactoryBean.setDataSource(dataSource); entityManagerFactoryBean.setJpaVendorAdapter(vendorAdapter); entityManagerFactoryBean.setJpaDialect(new HibernateJpaDialect()); entityManagerFactoryBean.setPackagesToScan(Organization.class.getPackage().getName()); entityManagerFactoryBean.setPersistenceUnitName("mysqlsource2"); entityManagerFactoryBean.afterPropertiesSet(); return entityManagerFactoryBean; }
/** * Container managed JPA * This bean replaces <code>persistence.xml</code> * Defines packages to scan with {@link javax.persistence.Entity} annotation * @return Entity manager factory */ @Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource, JpaVendorAdapter jpaVendorAdapter){ LocalContainerEntityManagerFactoryBean emfb = new LocalContainerEntityManagerFactoryBean(); emfb.setDataSource(dataSource); emfb.setJpaVendorAdapter(jpaVendorAdapter); emfb.setPackagesToScan(PACKAGE_TO_SCAN_ENTITIES); return emfb; }
/** * JPA vendor adapter provides specifics about particular JPA implementation to use * @return JPA vendor adapter */ @Bean public JpaVendorAdapter jpaVendorAdapter(Environment env){ HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter(); adapter.setDatabase(Database.POSTGRESQL); adapter.setShowSql(Boolean.parseBoolean(env.getProperty(PROPERTY_JPA_SHOW_SQL))); adapter.setDatabasePlatform(env.getProperty(PROPERTY_JPA_DATABASE_PLATFORM)); adapter.setGenerateDdl(Boolean.parseBoolean(env.getProperty(PROPERTY_JPA_GENERATE_DDL))); return adapter; }
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() { LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource()); em.setPackagesToScan(new String[] { "com.bats.criteriagenerator.entity" }); JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); em.setJpaVendorAdapter(vendorAdapter); em.setJpaProperties(additionalProperties()); return em; }
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() { LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource()); em.setPackagesToScan(new String[] { "com.iisigroup.domain" }); JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); em.setJpaVendorAdapter(vendorAdapter); em.setJpaProperties(hibernateProperties()); return em; }
@Bean public JpaVendorAdapter jpaVendorAdapter() { HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter(); hibernateJpaVendorAdapter.setShowSql(false); hibernateJpaVendorAdapter.setGenerateDdl(false); hibernateJpaVendorAdapter.setDatabase(Database.H2); return hibernateJpaVendorAdapter; }
@Bean public EntityManagerFactory entityManagerFactory(JpaVendorAdapter jpaVendorAdapter, DataSource dataSource) { LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setJpaVendorAdapter(jpaVendorAdapter); factory.setPackagesToScan("todolist.entities"); factory.setDataSource(dataSource); factory.afterPropertiesSet(); return factory.getObject(); }
@Bean public JpaVendorAdapter jpaVendorAdapter() { HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter(); hibernateJpaVendorAdapter.setShowSql(false); hibernateJpaVendorAdapter.setGenerateDdl(true); hibernateJpaVendorAdapter.setDatabase(Database.H2); return hibernateJpaVendorAdapter; }
@Bean public EntityManagerFactory entityManagerFactory(JpaVendorAdapter jpaVendorAdapter, DataSource dataSource) { LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setJpaVendorAdapter(jpaVendorAdapter); factory.setPackagesToScan("hello.entities"); factory.setDataSource(dataSource); factory.afterPropertiesSet(); return factory.getObject(); }
/** * Creates the entity manager factory. * * @param dataSource the data source to use * @return entity manager factory */ @Bean @Primary public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource) { LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean(); entityManagerFactoryBean.setDataSource(dataSource); JpaVendorAdapter jpaVendorAdapter = createJpaVendorAdapter(); entityManagerFactoryBean.setJpaVendorAdapter(jpaVendorAdapter); Map<String, String> jpaPropertyMap = getJpaPropertyMap(); entityManagerFactoryBean.setJpaPropertyMap(jpaPropertyMap); getMappingResources().ifPresent(entityManagerFactoryBean::setMappingResources); getPackagesToScan().ifPresent(entityManagerFactoryBean::setPackagesToScan); // https://hibernate.atlassian.net/browse/HHH-5303#comment-44439 entityManagerFactoryBean.setSharedCacheMode(ENABLE_SELECTIVE); customizeEntityManagerFactoryBean(entityManagerFactoryBean); return entityManagerFactoryBean; }
@Bean public JpaVendorAdapter jpaVendorAdapter() { HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter(); adapter.setDatabasePlatform("org.hibernate.dialect.MySQL5InnoDBDialect"); adapter.setGenerateDdl(true); return adapter; }
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory(final DataSource dataSource) { LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource); em.setPackagesToScan(new String[] { "com.ge.predix.acs.service.policy.admin.dao", "com.ge.predix.acs.privilege.management.dao", "com.ge.predix.acs.zone.management.dao", "com.ge.predix.acs.attribute.connector.management.dao" }); JpaVendorAdapter vendorAdapter = new OpenJpaVendorAdapter(); em.setJpaVendorAdapter(vendorAdapter); return em; }
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource, JpaVendorAdapter jpaVendorAdapter) { LocalContainerEntityManagerFactoryBean lef = new LocalContainerEntityManagerFactoryBean(); lef.setDataSource(dataSource); lef.setJpaVendorAdapter(jpaVendorAdapter); lef.setPackagesToScan("com.fetoxdevelopments.wormboard.domain"); return lef; }
@Bean public JpaVendorAdapter jpaVendorAdapter() { HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter(); hibernateJpaVendorAdapter.setShowSql(false); hibernateJpaVendorAdapter.setGenerateDdl(false); hibernateJpaVendorAdapter.setDatabase(Database.POSTGRESQL); return hibernateJpaVendorAdapter; }
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource) { LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource); em.setPackagesToScan(new String[] { "br.org.ismart.ismartonline.models" }); JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); em.setJpaVendorAdapter(vendorAdapter); em.setJpaProperties(additionalProperties()); return em; }
@Bean // configuta EntityManager public LocalContainerEntityManagerFactoryBean entityManagerFactory( DataSource dataSource) { LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource); em.setPackagesToScan(new String[]{"br.com.semanticwot.cd.models"}); JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); em.setJpaVendorAdapter(vendorAdapter); em.setJpaProperties(additionalProperties()); return em; }
@Bean public JpaVendorAdapter jpaVendorAdapter() { final HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter(); adapter.setDatabase(Database.MYSQL); adapter.setShowSql(true); adapter.setGenerateDdl(true); adapter.setDatabasePlatform("org.hibernate.dialect.MySQL5InnoDBDialect"); return adapter; }
@Bean public JpaVendorAdapter jpaVendorAdapter() { HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter(); adapter.setDatabase(Database.MYSQL); adapter.setGenerateDdl(true); return adapter; }
@Bean(name = "entityManagerFactoryBean") protected LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() { final LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean(); final JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); factoryBean.setPackagesToScan("net.iaeste.iws.persistence"); factoryBean.setDataSource(dataSource()); factoryBean.setJpaVendorAdapter(vendorAdapter); factoryBean.setJpaProperties(jpaProperties()); return factoryBean; }
@Bean protected LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() { final LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean(); final JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); factoryBean.setPackagesToScan("net.iaeste.iws.persistence"); factoryBean.setDataSource(dataSource()); factoryBean.setJpaVendorAdapter(vendorAdapter); factoryBean.setJpaProperties(jpaProperties()); return factoryBean; }
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() { LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource()); em.setPackagesToScan("org.demis.comics.data.jpa.entity"); JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); em.setJpaVendorAdapter(vendorAdapter); em.setJpaProperties(additionalProperties()); return em; }