Spring Framework LocalContainerEntityManagerFactoryBean - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework LocalContainerEntityManagerFactoryBean class.

This code example shows how to use the following methods:setDataSource, setPackagesToScan, setPersistenceUnitName, setJpaVendorAdapter
	} 
 
	@Bean 
	public LocalContainerEntityManagerFactoryBean entityManagerFactory() { 
 
		LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); 
		em.setPersistenceUnitName("spring-data-jpa"); 
		em.setDataSource(dataSource()); 
		em.setJpaVendorAdapter(jpaVendorAdapter()); 
		em.setPackagesToScan("purejavaconfig"); 
 
		return em; 
	} 
} 
7
CodeRank
This code example shows how to use the following methods:setDataSource, setPersistenceUnitName, afterPropertiesSet, getObject, setPersistenceProviderClass
    flyway.migrate(); 
  } 
 
  @SuppressWarnings({ "rawtypes", "unchecked" }) 
  private static EntityManager entityManager(DataSource dataSource) { 
    LocalContainerEntityManagerFactoryBean emfBean = new LocalContainerEntityManagerFactoryBean(); 
    emfBean.setDataSource(dataSource); 
    emfBean.setPersistenceUnitName(PERSISTENCE_UNIT_NAME); 
    emfBean.setPersistenceProviderClass(PERSISTENCE_PROVIDER_CLASS); 
    emfBean.afterPropertiesSet(); 
    Map map = new HashMap<String, String>(); 
    map.put("openjpa.ConnectionFactoryProperties", "PrintParameters=true"); 
    return emfBean.getObject().createEntityManager(map); 
  } 
 
  private static DataSource dataSource() { 
    DataSource dataSource = new DataSource(); 
    dataSource.setDriverClassName("org.hsqldb.jdbcDriver"); 
    dataSource.setUrl("jdbc:hsqldb:file:target/db;shutdown=true"); 
    dataSource.setUsername("sa"); 
7
CodeRank
This code example shows how to use the following methods:setDataSource, setPackagesToScan, afterPropertiesSet, getObject, setJpaPropertyMap
	public EntityManagerFactory entityManagerFactory() { 
 
		HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); 
		vendorAdapter.setGenerateDdl(true); 
 
		LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); 
		factory.setJpaVendorAdapter(vendorAdapter); 
		factory.setPackagesToScan("org.springframework.issues.domain"); 
		factory.setDataSource(h2Database()); 
		factory.setJpaPropertyMap(Collections.singletonMap("hibernate.show_sql", "true")); 
		factory.afterPropertiesSet(); 
 
		return factory.getObject(); 
	} 
 
	@Bean 
	public PlatformTransactionManager transactionManager() { 
 
		JpaTransactionManager txManager = new JpaTransactionManager(); 
		txManager.setEntityManagerFactory(entityManagerFactory()); 
7
CodeRank
This code example shows how to use the following methods:setDataSource, setPersistenceXmlLocation, afterPropertiesSet, getObject, setPersistenceProvider
        return new JpaTransactionManager(entityManagerFactory()); 
    } 
 
    @Bean 
    public EntityManagerFactory entityManagerFactory() { 
        LocalContainerEntityManagerFactoryBean bean = new LocalContainerEntityManagerFactoryBean(); 
        bean.setDataSource(dataSource); 
        bean.setPersistenceProvider(new HibernatePersistence()); 
        bean.setPersistenceXmlLocation("classpath:META-INF/persistence.xml"); 
        bean.afterPropertiesSet(); 
        return bean.getObject(); 
    } 
 
    @Bean 
    public LibraryService libraryService() { 
        return new LibraryService(); 
    } 
} 
7
CodeRank
This code example shows how to use the following methods:setDataSource, setPersistenceXmlLocation, afterPropertiesSet, getObject
        return new JpaTransactionManager(entityManagerFactory()); 
    } 
 
    @Bean 
    public EntityManagerFactory entityManagerFactory() { 
        LocalContainerEntityManagerFactoryBean bean = new LocalContainerEntityManagerFactoryBean(); 
        bean.setDataSource(dataSource()); 
        bean.setPersistenceXmlLocation("classpath:META-INF/persistence.xml"); 
        bean.afterPropertiesSet(); 
        return bean.getObject(); 
    } 
 
    @Bean 
    public LibraryService libraryService() { 
        return new LibraryService(); 
    } 
} 
7
CodeRank
This code example shows how to use the following methods:setDataSource, setPackagesToScan, setPersistenceUnitName, afterPropertiesSet, setJpaProperties
    
    @Bean 
    public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean(){ 
       
	    LocalContainerEntityManagerFactoryBean lcemfb 
            = new LocalContainerEntityManagerFactoryBean(); 
	    
        lcemfb.setDataSource(this.dataSource()); 
        lcemfb.setPackagesToScan(new String[] {"com.jverstry"}); 
		lcemfb.setPersistenceUnitName("MyTestPU"); 
		 
        HibernateJpaVendorAdapter va = new HibernateJpaVendorAdapter(); 
		lcemfb.setJpaVendorAdapter(va); 
		 
		Properties ps = new Properties(); 
		ps.put("hibernate.dialect", "org.hibernate.dialect.HSQLDialect"); 
		ps.put("hibernate.hbm2ddl.auto", "create"); 
		lcemfb.setJpaProperties(ps); 
		 
		lcemfb.afterPropertiesSet(); 

6
CodeRank
This code example shows how to use the following methods:setDataSource, setPackagesToScan, afterPropertiesSet, getObject, setJpaProperties
        return entityManagerFactory.createEntityManager(); 
    } 
 
    @Bean 
    public EntityManagerFactory entityManagerFactory() { 
        LocalContainerEntityManagerFactoryBean entityManagerFactory = new LocalContainerEntityManagerFactoryBean(); 
 
        entityManagerFactory.setPackagesToScan("com.sequenceiq.cloudbreak.domain"); 
        entityManagerFactory.setDataSource(dataSource()); 
 
        entityManagerFactory.setJpaVendorAdapter(jpaVendorAdapter()); 
        entityManagerFactory.setJpaProperties(jpaProperties()); 
        entityManagerFactory.afterPropertiesSet(); 
        return entityManagerFactory.getObject(); 
    } 
 
    @Bean 
    public JpaVendorAdapter jpaVendorAdapter() { 
        HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter(); 
        hibernateJpaVendorAdapter.setShowSql(true); 
6
CodeRank
This code example shows how to use the following methods:setDataSource, setJpaVendorAdapter
    @Autowired 
    private EntityManagerFactory entityManagerFactory; 
 
    @Bean 
    public FactoryBean<EntityManagerFactory> entityManagerFactory() { 
        LocalContainerEntityManagerFactoryBean emfb = new LocalContainerEntityManagerFactoryBean(); 
        emfb.setDataSource(this.dataSource); 
        emfb.setJpaVendorAdapter(jpaVendorAdapter()); 
        return emfb; 
    } 
 
    @Bean 
    public JpaVendorAdapter jpaVendorAdapter() { 
        return new HibernateJpaVendorAdapter(); 
    } 
 
    @Bean 
    public PlatformTransactionManager transactionManager() { 
        JpaTransactionManager txManager = new JpaTransactionManager(); 
        txManager.setEntityManagerFactory(this.entityManagerFactory); 
6
CodeRank
This code example shows how to use the following methods:setDataSource, setPackagesToScan, setJpaPropertyMap, setJpaVendorAdapter
            return new JpaTransactionManager( entityManagerFactory().getObject() ); 
    } 
 
    @Bean 
    public LocalContainerEntityManagerFactoryBean entityManagerFactory() { 
            LocalContainerEntityManagerFactoryBean lef = new LocalContainerEntityManagerFactoryBean(); 
            lef.setDataSource(dataSource()); 
            lef.setJpaPropertyMap(this.jpaProperties()); 
            lef.setJpaVendorAdapter(this.jpaVendorAdapter()); 
            lef.setPackagesToScan("hello"); 
            return lef; 
    } 
	 
} 
6
CodeRank
This code example shows how to use the following methods:setDataSource, setPackagesToScan, setJpaVendorAdapter, setPersistenceProvider
 
    @Bean 
    public LocalContainerEntityManagerFactoryBean entityManagerFactory() { 
        HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); 
        vendorAdapter.setGenerateDdl(true); 
        LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean(); 
        factoryBean.setJpaVendorAdapter(vendorAdapter); 
        factoryBean.setPersistenceProvider(new HibernatePersistence()); 
        factoryBean.setDataSource(dataSource()); 
        factoryBean.setPackagesToScan("rds.springdata"); 
        return factoryBean; 
    } 
 
    @Bean 
    public PlatformTransactionManager transactionManager(EntityManagerFactory entityManagerFactory) { 
        return new JpaTransactionManager(entityManagerFactory); 
    } 
} 
6
CodeRank
See Code Examples for Spring Framework LocalContainerEntityManagerFactoryBean Methods: