コード例 #1
1
  @Bean
  LocalContainerEntityManagerFactoryBean entityManagerFactory(
      DataSource dataSource, Environment env) {

    LocalContainerEntityManagerFactoryBean entityManagerFactoryBean =
        new LocalContainerEntityManagerFactoryBean();
    entityManagerFactoryBean.setDataSource(dataSource);
    entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
    entityManagerFactoryBean.setPackagesToScan("es.udc.lbd.rie");

    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"));

    // Configures the naming strategy that is used when Hibernate creates
    // new database objects and schema elements
    jpaProperties.put(
        "hibernate.ejb.naming_strategy", env.getRequiredProperty("hibernate.ejb.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 format the SQL
    // that is written to the console.
    jpaProperties.put("hibernate.format_sql", env.getRequiredProperty("hibernate.format_sql"));

    entityManagerFactoryBean.setJpaProperties(jpaProperties);

    return entityManagerFactoryBean;
  }
コード例 #2
1
  @Bean
  public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean()
      throws ClassNotFoundException {
    LocalContainerEntityManagerFactoryBean entityManagerFactoryBean =
        new LocalContainerEntityManagerFactoryBean();

    entityManagerFactoryBean.setDataSource(dataSource());
    entityManagerFactoryBean.setPackagesToScan(
        environment.getRequiredProperty(PROPERTY_NAME_ENTITYMANAGER_PACKAGES_TO_SCAN));
    entityManagerFactoryBean.setPersistenceProviderClass(HibernatePersistence.class);

    Properties jpaProterties = new Properties();
    jpaProterties.put(
        PROPERTY_NAME_HIBERNATE_DIALECT,
        environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_DIALECT));
    jpaProterties.put(
        PROPERTY_NAME_HIBERNATE_FORMAT_SQL,
        environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_FORMAT_SQL));
    jpaProterties.put(
        PROPERTY_NAME_HIBERNATE_NAMING_STRATEGY,
        environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_NAMING_STRATEGY));
    jpaProterties.put(
        PROPERTY_NAME_HIBERNATE_SHOW_SQL,
        environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_SHOW_SQL));

    entityManagerFactoryBean.setJpaProperties(jpaProterties);

    return entityManagerFactoryBean;
  }
コード例 #3
0
  @Bean
  public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean entityManagerFactoryBean =
        new LocalContainerEntityManagerFactoryBean();

    entityManagerFactoryBean.setDataSource(dataSource());
    entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
    entityManagerFactoryBean.setPackagesToScan(PROPERTY_PACKAGES_TO_SCAN);

    Properties jpaProperties = new Properties();

    jpaProperties.put(
        PROPERTY_NAME_HIBERNATE_DIALECT,
        environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_DIALECT));
    jpaProperties.put(
        PROPERTY_NAME_HIBERNATE_FORMAT_SQL,
        environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_FORMAT_SQL));
    jpaProperties.put(
        PROPERTY_NAME_HIBERNATE_HBM2DDL_AUTO,
        environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_HBM2DDL_AUTO));
    jpaProperties.put(
        PROPERTY_NAME_HIBERNATE_NAMING_STRATEGY,
        environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_NAMING_STRATEGY));
    jpaProperties.put(
        PROPERTY_NAME_HIBERNATE_SHOW_SQL,
        environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_SHOW_SQL));

    entityManagerFactoryBean.setJpaProperties(jpaProperties);

    return entityManagerFactoryBean;
  }
コード例 #4
0
 @Bean
 public LocalContainerEntityManagerFactoryBean localContainerEntityManagerFactoryBean() {
   LocalContainerEntityManagerFactoryBean lef = new LocalContainerEntityManagerFactoryBean();
   lef.setDataSource(this.dataSource);
   lef.setJpaPropertyMap(this.jpaProperties());
   lef.setJpaVendorAdapter(this.jpaVendorAdapter());
   return lef;
 }
コード例 #5
0
ファイル: DataBaseUtils.java プロジェクト: yilo/finger-city
 public static LocalContainerEntityManagerFactoryBean createEntityManagerFactory(
     DataSource eds, HibernateJpaVendorAdapter hJpa, String entityPkgName) {
   LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
   em.setDataSource(eds);
   em.setPackagesToScan(entityPkgName);
   em.setJpaVendorAdapter(hJpa);
   return em;
 }
コード例 #6
0
 @Bean
 public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
   LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
   em.setDataSource(dataSource());
   em.setLoadTimeWeaver(instrumentationLoadTimeWeaver());
   em.setPersistenceProviderClass(HibernatePersistenceProvider.class);
   return em;
 }
コード例 #7
0
 @Bean
 public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
   LocalContainerEntityManagerFactoryBean factoryBean =
       new LocalContainerEntityManagerFactoryBean();
   factoryBean.setDataSource(dataSource());
   factoryBean.setPersistenceUnitName("academico");
   return factoryBean;
 }
コード例 #8
0
 @Bean
 public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
   final LocalContainerEntityManagerFactoryBean bean =
       new LocalContainerEntityManagerFactoryBean();
   bean.setJpaVendorAdapter(hibernateJpaVendorAdapter());
   bean.setDataSource(dataSource());
   bean.setPackagesToScan("com.corriel.users.entity", "com.corriel.budget.entity");
   return bean;
 }
コード例 #9
0
 @Bean
 public FactoryBean<EntityManagerFactory> entityManagerFactory() {
   LocalContainerEntityManagerFactoryBean localContainerEntityManagerFactoryBean =
       new LocalContainerEntityManagerFactoryBean();
   localContainerEntityManagerFactoryBean.setJpaProperties(properties);
   localContainerEntityManagerFactoryBean.setDataSource(dataSource);
   localContainerEntityManagerFactoryBean.setJpaVendorAdapter(jpaVendorAdapter());
   return localContainerEntityManagerFactoryBean;
 }
コード例 #10
0
 /**
  * Configures the entity manager factory.
  *
  * <p>Sets the default data source using the <code>dataSource()</code> method. Sets JPA Vendor
  * adapter using the <code>jpaVendorAdapter()</code> method. Sets Hibernate properties using the
  * <code>hibernateProperties()</code> method. Entities in the package <code>org.wfp.fittest.entity
  * </code> are scanned automatically.
  *
  * @return LocalContainerEntityManagerFactoryBean
  * @see EntityManagerFactory
  */
 @Bean(name = "entityManagerFactory")
 public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
   LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
   em.setDataSource(dataSource());
   em.setPackagesToScan(new String[] {"org.wfp.fittest.entity"});
   em.setJpaVendorAdapter(jpaVendorAdapter());
   em.setJpaProperties(hibernateProperties());
   return em;
 }
 @Bean
 public LocalContainerEntityManagerFactoryBean entityManagerFactory(
     DataSource dataSource, JpaVendorAdapter jpaVendeorAdapter) {
   LocalContainerEntityManagerFactoryBean entityManagerFactory =
       new LocalContainerEntityManagerFactoryBean();
   entityManagerFactory.setDataSource(dataSource);
   entityManagerFactory.setJpaVendorAdapter(jpaVendeorAdapter);
   entityManagerFactory.setPackagesToScan("world.we.deserve.dto.jpa");
   return entityManagerFactory;
 }
コード例 #12
0
 @Bean
 public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
   LocalContainerEntityManagerFactoryBean entityManagerFactoryBean =
       new LocalContainerEntityManagerFactoryBean();
   entityManagerFactoryBean.setDataSource(dataSource());
   entityManagerFactoryBean.setJpaVendorAdapter(jpaVendorAdapter());
   entityManagerFactoryBean.setPackagesToScan("com.softserveinc.ita.kaiji");
   entityManagerFactoryBean.setJpaProperties(jpaProperties());
   return entityManagerFactoryBean;
 }
コード例 #13
0
  @Bean
  public LocalContainerEntityManagerFactoryBean entityManagerFactory() {

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setDataSource(dataSource());
    factory.setJpaVendorAdapter(jpaVendorAdapter());
    factory.setPackagesToScan("se.meer.jpa.model");

    return factory;
  }
コード例 #14
0
 @Bean
 public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
   final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
   em.setDataSource(dataSource());
   em.setPackagesToScan(new String[] {"com.sentinel.persistence.models"});
   final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
   em.setJpaVendorAdapter(vendorAdapter);
   em.setJpaProperties(additionalProperties());
   return em;
 }
コード例 #15
0
 @Bean
 public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
   LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
   emf.setDataSource(dataSource());
   JpaVendorAdapter jpaVendorAdapter = new HibernateJpaVendorAdapter();
   emf.setJpaVendorAdapter(jpaVendorAdapter);
   emf.setJpaProperties(jpaPropertiesForEMF());
   emf.setPackagesToScan(mappingPackagesToScan);
   return emf;
 }
コード例 #16
0
 @Bean
 public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
   LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
   em.setDataSource(dataSource());
   em.setPackagesToScan(new String[] {"ph.com.alliance.entity"});
   JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
   em.setJpaVendorAdapter(vendorAdapter);
   em.setJpaProperties(additionalProperties());
   return em;
 }
コード例 #17
0
    public LocalContainerEntityManagerFactoryBean build() {
      LocalContainerEntityManagerFactoryBean entityManagerFactoryBean =
          new LocalContainerEntityManagerFactoryBean();
      if (EntityManagerFactoryBuilder.this.persistenceUnitManager != null) {
        entityManagerFactoryBean.setPersistenceUnitManager(
            EntityManagerFactoryBuilder.this.persistenceUnitManager);
      }
      if (this.persistenceUnit != null) {
        entityManagerFactoryBean.setPersistenceUnitName(this.persistenceUnit);
      }
      entityManagerFactoryBean.setJpaVendorAdapter(
          EntityManagerFactoryBuilder.this.jpaVendorAdapter);

      if (this.jta) {
        entityManagerFactoryBean.setJtaDataSource(this.dataSource);
      } else {
        entityManagerFactoryBean.setDataSource(this.dataSource);
      }

      entityManagerFactoryBean.setPackagesToScan(this.packagesToScan);
      entityManagerFactoryBean
          .getJpaPropertyMap()
          .putAll(EntityManagerFactoryBuilder.this.jpaProperties);
      entityManagerFactoryBean.getJpaPropertyMap().putAll(this.properties);
      if (EntityManagerFactoryBuilder.this.callback != null) {
        EntityManagerFactoryBuilder.this.callback.execute(entityManagerFactoryBean);
      }
      return entityManagerFactoryBean;
    }
コード例 #18
0
 @Qualifier("user_manager")
 @Bean(name = "user_manager_EntityManagerFactory")
 public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
   final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
   em.setDataSource(dataSource());
   em.setPackagesToScan("com.bluntsoftware.MyApp.modules.user_manager.domain");
   final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
   em.setJpaVendorAdapter(vendorAdapter);
   em.setJpaProperties(additionalProperties());
   return em;
 }
コード例 #19
0
  @Bean
  public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setDatabase(Database.MYSQL);
    vendorAdapter.setGenerateDdl(true);

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan(getClass().getPackage().getName());
    factory.setDataSource(dataSource());
    return factory;
  }
コード例 #20
0
  @Bean
  public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource) {
    LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
    emf.setDataSource(dataSource);
    emf.setPackagesToScan(new String[] {"com.urbanhive.model"});

    JpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
    emf.setJpaVendorAdapter(adapter);
    emf.setJpaProperties(otherProperties());

    return emf;
  }
コード例 #21
0
 @Bean
 LocalContainerEntityManagerFactoryBean entityManagerFactory() {
   LocalContainerEntityManagerFactoryBean factoryBean =
       new LocalContainerEntityManagerFactoryBean();
   HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
   vendorAdapter.setDatabase(Database.MYSQL);
   vendorAdapter.setGenerateDdl(true);
   vendorAdapter.setShowSql(false);
   factoryBean.setPackagesToScan("com.magic.app.**.entities");
   factoryBean.setJpaVendorAdapter(vendorAdapter);
   factoryBean.setDataSource(dataSource());
   return factoryBean;
 }
コード例 #22
0
  @Bean
  public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();

    emf.setDataSource(dataSource());
    emf.setPackagesToScan(new String[] {"com.nuance.vdmach.model.entities"});

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

    return emf;
  }
コード例 #23
0
ファイル: DataConfig.java プロジェクト: MynaDima/-Monitoring
  @Bean
  public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean entityManagerFactoryBean =
        new LocalContainerEntityManagerFactoryBean();
    entityManagerFactoryBean.setDataSource(dataSource());
    entityManagerFactoryBean.setPersistenceProviderClass(HibernatePersistence.class);
    entityManagerFactoryBean.setPackagesToScan(
        env.getRequiredProperty(PROP_ENTITYMANAGER_PACKAGES_TO_SCAN));

    entityManagerFactoryBean.setJpaProperties(getHibernateProperties());

    return entityManagerFactoryBean;
  }
コード例 #24
0
  @Bean(name = "entityManagerFactory")
  public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() {
    LocalContainerEntityManagerFactoryBean factoryBean =
        new LocalContainerEntityManagerFactoryBean();
    factoryBean.setDataSource(dataSource());
    factoryBean.setPersistenceUnitName("a1ecommerceEntityManager");
    factoryBean.setPackagesToScan(new String[] {"com.a1electronics.ecommerce.dbo"});
    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    factoryBean.setJpaVendorAdapter(vendorAdapter);
    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"));

    // 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 format the SQL
    // that is written to the console.
    jpaProperties.put("hibernate.format_sql", env.getRequiredProperty("hibernate.format_sql"));
    // jpaProperties.put("hibernate.hbm2ddl.auto",env.getRequiredProperty("hibernate.hbm2ddl.auto"));
    // To fix the followinf issue
    // HHH000424: Disabling contextual LOB creation as createClob() method threw error :
    // java.lang.reflect.InvocationTargetException
    jpaProperties.put("hibernate.temp.use_jdbc_metadata_defaults", false);

    factoryBean.setJpaProperties(jpaProperties);
    factoryBean.afterPropertiesSet();
    factoryBean.setLoadTimeWeaver(new InstrumentationLoadTimeWeaver());
    //		factoryBean.setPersistenceUnitName(env.getRequiredProperty("persistence.unitName"));
    return factoryBean;
  }
コード例 #25
0
  @Bean
  public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean(DataSource dSource) {
    LocalContainerEntityManagerFactoryBean factoryBean =
        new LocalContainerEntityManagerFactoryBean();

    factoryBean.setDataSource(dSource);
    factoryBean.setPackagesToScan(new String[] {"model"});

    JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();

    factoryBean.setJpaVendorAdapter(vendorAdapter);
    factoryBean.setJpaProperties(addtionalProperties());

    return factoryBean;
  }
コード例 #26
0
  @Bean
  public LocalContainerEntityManagerFactoryBean configureEntityManagerFactory() {
    LocalContainerEntityManagerFactoryBean entityManagerFactoryBean =
        new LocalContainerEntityManagerFactoryBean();
    entityManagerFactoryBean.setDataSource(configureDataSource());
    entityManagerFactoryBean.setPackagesToScan("basic");
    entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());

    Properties jpaProperties = new Properties();
    jpaProperties.put(org.hibernate.cfg.Environment.DIALECT, dialect);
    jpaProperties.put(org.hibernate.cfg.Environment.HBM2DDL_AUTO, hbm2ddlAuto);
    entityManagerFactoryBean.setJpaProperties(jpaProperties);

    return entityManagerFactoryBean;
  }
コード例 #27
0
  @Bean
  public LocalContainerEntityManagerFactoryBean configureEntityManagerFactory() {
    LocalContainerEntityManagerFactoryBean entityManagerFactoryBean =
        new LocalContainerEntityManagerFactoryBean();
    entityManagerFactoryBean.setDataSource(configureDataSource());
    entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
    entityManagerFactoryBean.setPackagesToScan(
        "com.bs.service.firmacentralizada.auditoria.entidades");
    Properties jpaProperties = new Properties();
    jpaProperties.put(org.hibernate.cfg.Environment.SHOW_SQL, true);
    jpaProperties.put(org.hibernate.cfg.Environment.FORMAT_SQL, true);
    entityManagerFactoryBean.setJpaProperties(jpaProperties);

    return entityManagerFactoryBean;
  }
コード例 #28
0
  @Bean
  public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource());
    em.setPackagesToScan(new String[] {"com.miller.timekeep"});

    JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    em.setJpaVendorAdapter(vendorAdapter);
    Properties properties = new Properties();
    properties.setProperty("hibernate.hbm2ddl.auto", "update");
    properties.setProperty("hibernate.show_sql", "true");
    properties.setProperty("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
    em.setJpaProperties(properties);
    return em;
  }
コード例 #29
0
  @Bean
  public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean entityManagerFactoryBean =
        new LocalContainerEntityManagerFactoryBean();

    entityManagerFactoryBean.setDataSource(dataSource());
    entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
    entityManagerFactoryBean.setPackagesToScan(PACKAGES_TO_SCAN);

    Properties jpaProperties = new Properties();
    jpaProperties.put("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect");
    jpaProperties.put("hibernate.show_sql", "true");

    entityManagerFactoryBean.setJpaProperties(jpaProperties);

    return entityManagerFactoryBean;
  }
コード例 #30
0
  @Bean
  public EntityManagerFactory entityManagerFactory() {

    Properties jpaProterties = new Properties();
    jpaProterties.put("hibernate.dialect", environment.getRequiredProperty("hibernate.dialect"));
    jpaProterties.put(
        "hibernate.format_sql", environment.getRequiredProperty("hibernate.format_sql"));
    jpaProterties.put(
        "hibernate.ejb.naming_strategy",
        environment.getRequiredProperty("hibernate.ejb.naming_strategy"));
    jpaProterties.put("hibernate.show_sql", environment.getRequiredProperty("hibernate.show_sql"));
    jpaProterties.put(
        "hibernate.generate_statistics",
        environment.getRequiredProperty("hibernate.generate_statistics"));

    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setGenerateDdl(false);

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan("br.com.uol.cubus.support.domain");
    factory.setDataSource(dataSource());
    factory.setJpaProperties(jpaProterties);
    factory.afterPropertiesSet();

    return factory.getObject();
  }