List of usage examples for org.springframework.orm.jpa LocalContainerEntityManagerFactoryBean setPersistenceXmlLocation
public void setPersistenceXmlLocation(String persistenceXmlLocation)
From source file:org.activiti.spring.test.jpa.JPASpringTest.java
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean( OpenJpaVendorAdapter openJpaVendorAdapter, DataSource ds) { LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean(); emf.setPersistenceXmlLocation("classpath:/org/activiti/spring/test/jpa/custom-persistence.xml"); emf.setJpaVendorAdapter(openJpaVendorAdapter); emf.setDataSource(ds);/*from w w w. j av a 2 s . c o m*/ return emf; }
From source file:org.unitils.orm.jpa.util.JpaEntityManagerFactoryLoader.java
/** * @param testObject The test instance, not null * @param jpaConfig The configuration parameters for the <code>EntityManagerFactory</code> * @return A completely configured <code>AbstractEntityManagerFactoryBean</code> *//* w w w . j a v a2s. c om*/ protected AbstractEntityManagerFactoryBean createEntityManagerFactoryBean(Object testObject, JpaConfig jpaConfig) { LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean(); factoryBean.setDataSource(getDataSource()); factoryBean.setJpaVendorAdapter(getJpaProviderSupport().getSpringJpaVendorAdaptor()); String persistenceXmlFile = jpaConfig.getConfigFiles().iterator().next(); if (!StringUtils.isEmpty(persistenceXmlFile)) { factoryBean.setPersistenceXmlLocation(persistenceXmlFile); } factoryBean.setPersistenceUnitName(jpaConfig.getPersistenceUnitName()); LoadTimeWeaver loadTimeWeaver = getJpaProviderSupport().getLoadTimeWeaver(); if (loadTimeWeaver != null) { factoryBean.setLoadTimeWeaver(loadTimeWeaver); } if (jpaConfig.getConfigMethod() != null) { try { ReflectionUtils.invokeMethod(testObject, jpaConfig.getConfigMethod(), factoryBean); } catch (InvocationTargetException e) { throw new UnitilsException("Error while invoking custom config method", e.getCause()); } } factoryBean.afterPropertiesSet(); return factoryBean; }