List of usage examples for org.springframework.orm.jpa LocalContainerEntityManagerFactoryBean setJpaVendorAdapter
public void setJpaVendorAdapter(@Nullable JpaVendorAdapter jpaVendorAdapter)
From source file:br.sp.mandala.config.AppConfiguration.java
@Bean LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource, Environment env) { LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean(); entityManagerFactoryBean.setDataSource(dataSource); entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter()); entityManagerFactoryBean.setPackagesToScan(ENTITY_PACKAGES); Properties jpaProperties = new Properties(); //Configures the used database dialect. This allows Hibernate to create SQL //that is optimized for the used database. jpaProperties.put(HIBERNATE_DIALECT, env.getRequiredProperty(HIBERNATE_DIALECT)); //Specifies the action that is invoked to the database when the Hibernate //SessionFactory is created or closed. jpaProperties.put(HIBERNATE_HBM2DDL_AUTO, env.getRequiredProperty(HIBERNATE_HBM2DDL_AUTO)); //Configures the naming strategy that is used when Hibernate creates //new database objects and schema elements jpaProperties.put(HIBERNATE_NAMING_STRATEGY, env.getRequiredProperty(HIBERNATE_NAMING_STRATEGY)); //If the value of this property is true, Hibernate writes all SQL //statements to the console. jpaProperties.put(HIBERNATE_SHOW_SQL, env.getRequiredProperty(HIBERNATE_SHOW_SQL)); //If the value of this property is true, Hibernate will use prettyprint //when it writes SQL to the console. jpaProperties.put(HIBERNATE_FORMAT_SQL, env.getRequiredProperty(HIBERNATE_FORMAT_SQL)); entityManagerFactoryBean.setJpaProperties(jpaProperties); return entityManagerFactoryBean; }
From source file:com.devnexus.ting.config.PersistenceConfig.java
@Bean @Profile({ SpringProfile.STANDALONE, SpringProfile.DEFAULT, SpringProfile.DEMO, SpringProfile.CLOUD }) public LocalContainerEntityManagerFactoryBean entityManagerFactory() { final LocalContainerEntityManagerFactoryBean entityManagerFactory = new LocalContainerEntityManagerFactoryBean(); entityManagerFactory.setDataSource(dataSource()); entityManagerFactory.setJpaVendorAdapter(hibernateJpaVendorAdapter()); entityManagerFactory.setPackagesToScan(PERSISTENCE_BASE_PACKAGE); final Map<String, Object> jpaProperties = new HashMap<>(); jpaProperties.put("hibernate.dialect", this.jpaSettings.getProperties().get("dialect")); jpaProperties.put("hibernate.generate_statistics", false); jpaProperties.put("hibernate.show_sql", this.jpaSettings.isShowSql()); jpaProperties.put("hibernate.format_sql", true); jpaProperties.put("hibernate.implicit_naming_strategy", DevNexusSpringImplicitNamingStrategy.class.getName()); jpaProperties.put("hibernate.physical_naming_strategy", SpringPhysicalNamingStrategy.class.getName()); entityManagerFactory.setJpaPropertyMap(jpaProperties); return entityManagerFactory; }
From source file:net.ljcomputing.config.PersistenceConfiguration.java
/** * Entity manager factory./*from w ww.j a va2 s . c o m*/ * * @return the entity manager factory */ @Bean public EntityManagerFactory entityManagerFactory() { final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); vendorAdapter.setGenerateDdl(true); final LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setJpaVendorAdapter(vendorAdapter); factory.setPackagesToScan("net.ljcomputing.entity"); factory.setDataSource(dataSource()); factory.afterPropertiesSet(); return factory.getObject(); }
From source file:com.iopr.PersistenceJPAConfig.java
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() { LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource());/*from w w w .ja va 2 s . c om*/ em.setPackagesToScan(new String[] { "com.iopr.model" }); JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); em.setJpaVendorAdapter(vendorAdapter); em.setJpaProperties(additionalProperties()); return em; }
From source file:com.orangeandbronze.jblubble.sample.BlobstoreSampleAppConfig.java
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() { LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean(); entityManagerFactoryBean.setDataSource(dataSource()); entityManagerFactoryBean.setPackagesToScan("com.orangeandbronze.jblubble.sample"); entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter()); Properties jpaProperties = new Properties(); jpaProperties.setProperty("javax.persistence.schema-generation.database.action", "none"); jpaProperties.setProperty("hibernate.dialect", "org.hibernate.dialect.HSQLDialect"); entityManagerFactoryBean.setJpaProperties(jpaProperties); return entityManagerFactoryBean; }
From source file:com.store.PersistenceJPAConfig.java
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() { LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource());//ww w .j a v a 2 s . com em.setPackagesToScan(new String[] { "com.store.model" }); JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); em.setJpaVendorAdapter(vendorAdapter); em.setJpaProperties(additionalProperties()); return em; }
From source file:cz.lbenda.coursing.client.ClientAppConfig.java
public @Bean EntityManagerFactory entityManagerFactory() { try {//from w w w . java 2 s.c o m EclipseLinkJpaVendorAdapter vendorAdapter = new EclipseLinkJpaVendorAdapter(); vendorAdapter.setDatabasePlatform("org.eclipse.persistence.platform.database.H2Platform"); vendorAdapter.setShowSql(true); vendorAdapter.setGenerateDdl(true); EclipseLinkJpaDialect dialect = new EclipseLinkJpaDialect(); dialect.setLazyDatabaseTransaction(true); LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setJpaVendorAdapter(vendorAdapter); factory.setJpaDialect(dialect); factory.setPackagesToScan("cz.lbenda.coursing"); factory.setDataSource(dataSource()); factory.setPersistenceXmlLocation("classpath*:META-INF/persistence.xml"); factory.setPersistenceUnitName("coursing"); /* Map<String, String> prop = new HashMap<>(); prop.put("eclipselink.deploy-on-startup", "true"); prop.put("eclipselink.ddl-generation", "create-or-extend-tables"); prop.put("eclipselink.ddl-generation.output-mode", "database"); prop.put("eclipselink.create-ddl-jdbc-file-name", "create.sql"); prop.put("eclipselink.weaving", "static"); prop.put("eclipselink.weaving.lazy", "true"); prop.put("eclipselink.weaving.internal", "true"); prop.put("eclipselink.logging.level", "SEVERE"); prop.put("eclipselink.query-results-cache.type", "WEAK"); prop.put("eclipselink.jdbc.batch-writing", "JDBC"); prop.put("eclipselink.jdbc.batch-writing.size", "1000"); factory.setJpaPropertyMap(prop); */ // factory.setLoadTimeWeaver(new InstrumentationLoadTimeWeaver()); factory.afterPropertiesSet(); return factory.getObject(); } catch (Exception e) { LOG.trace("Faild create entityManagerFactory", e); throw new RuntimeException("Faild create entityManagerFactory", e); } }
From source file:br.com.joaops.awc.configuration.PersistenceConfig.java
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() { LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource());// w ww . j a v a2 s . c om em.setPackagesToScan(this.getPackagesToScan()); JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); em.setJpaVendorAdapter(vendorAdapter); em.setJpaProperties(getAdditionalProperties()); return em; }
From source file:com.space.data.DomainStoreConfiguration.java
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() { LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource());//from w ww . j av a 2 s . c o m em.setPackagesToScan(new String[] { "com.space.data.model" }); JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); em.setJpaVendorAdapter(vendorAdapter); em.setJpaProperties(additionalProperties()); return em; }
From source file:calculus.backend.JpaConfig.java
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() { HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); vendorAdapter.setDatabase(this.dataBase); vendorAdapter.setGenerateDdl(true);/*ww w . java2s . c o m*/ LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setJpaVendorAdapter(vendorAdapter); factory.setPackagesToScan("calculus.backend.model"); factory.setDataSource(dataSource()); factory.setJpaProperties(propiedadesAdicionalesJpa()); return factory; }