本文整理汇总了Java中org.springframework.orm.jpa.AbstractEntityManagerFactoryBean类的典型用法代码示例。如果您正苦于以下问题:Java AbstractEntityManagerFactoryBean类的具体用法?Java AbstractEntityManagerFactoryBean怎么用?Java AbstractEntityManagerFactoryBean使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AbstractEntityManagerFactoryBean类属于org.springframework.orm.jpa包,在下文中一共展示了AbstractEntityManagerFactoryBean类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerBeanDefinitions
import org.springframework.orm.jpa.AbstractEntityManagerFactoryBean; //导入依赖的package包/类
@Override
public void registerBeanDefinitions(AnnotationMetadata annotationMetadata, BeanDefinitionRegistry registry) {
// Register JPA Datastore (transactional)
if (beanFactory instanceof ListableBeanFactory) {
String[] emfBeanNames = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(
(ListableBeanFactory) beanFactory, EntityManagerFactory.class, true, false);
if (emfBeanNames == null || emfBeanNames.length == 0) {
emfBeanNames = BeanFactoryUtils.beanNamesForTypeIncludingAncestors((ListableBeanFactory) beanFactory,
AbstractEntityManagerFactoryBean.class, true, false);
}
if (emfBeanNames != null && emfBeanNames.length == 1) {
String emfBeanName = (emfBeanNames[0].startsWith("&")) ? emfBeanNames[0].substring(1) : emfBeanNames[0];
JpaDatastoreRegistrar.registerDatastore(registry, null, PrimaryMode.AUTO, emfBeanName, true, false,
beanClassLoader);
}
}
}
开发者ID:holon-platform,项目名称:holon-datastore-jpa,代码行数:18,代码来源:JpaDatastoreAutoConfigurationRegistrar.java
示例2: createEntityManagerFactoryBean
import org.springframework.orm.jpa.AbstractEntityManagerFactoryBean; //导入依赖的package包/类
/**
* @param testObject The test instance, not null
* @param jpaConfig The configuration parameters for the <code>EntityManagerFactory</code>
* @return A completely configured <code>AbstractEntityManagerFactoryBean</code>
*/
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;
}
示例3: postProcessBeforeInitialization
import org.springframework.orm.jpa.AbstractEntityManagerFactoryBean; //导入依赖的package包/类
@Override
public Object postProcessBeforeInitialization(final Object bean, final String beanName) throws BeansException {
if(bean instanceof AbstractEntityManagerFactoryBean){
SpringCacheRegionFactory.SPRING_CACHE_MANAGER.set( cacheManager );
beanNames.add( beanName );
}
return bean;
}
开发者ID:candrews,项目名称:hibernate-springcache,代码行数:9,代码来源:SpringCacheRegionFactoryBeanPostProcessor.java
示例4: getConfiguredPersistenceUnit
import org.springframework.orm.jpa.AbstractEntityManagerFactoryBean; //导入依赖的package包/类
public ConfiguredOrmPersistenceUnit<EntityManagerFactory, Object> getConfiguredPersistenceUnit(Object testObject) {
AbstractEntityManagerFactoryBean factoryBean = getEntityManagerFactoryBean(testObject);
EntityManagerFactory entityManagerFactory = factoryBean.getObject();
Object providerSpecificConfigurationObject = getJpaModule().getJpaProviderSupport().getProviderSpecificConfigurationObject(factoryBean.getPersistenceProvider());
return new ConfiguredOrmPersistenceUnit<EntityManagerFactory, Object>(entityManagerFactory, providerSpecificConfigurationObject);
}
示例5: getEntityManagerFactoryBean
import org.springframework.orm.jpa.AbstractEntityManagerFactoryBean; //导入依赖的package包/类
/**
* @param testObject The test instance, not null
* @return Instance of {@link LocalSessionFactoryBean} that wraps the configuration of hibernate in spring
*/
protected AbstractEntityManagerFactoryBean getEntityManagerFactoryBean(Object testObject) {
if (!getSpringModule().isApplicationContextConfiguredFor(testObject)) {
return null;
}
Collection<?> entityManagerFactoryBeans = getSpringModule().getApplicationContext(testObject).getBeansOfType(AbstractEntityManagerFactoryBean.class).values();
if (entityManagerFactoryBeans.size() == 0) {
return null;
}
return (AbstractEntityManagerFactoryBean) entityManagerFactoryBeans.iterator().next();
}
示例6: entityManagerFactory
import org.springframework.orm.jpa.AbstractEntityManagerFactoryBean; //导入依赖的package包/类
@Bean
public AbstractEntityManagerFactoryBean entityManagerFactory(DataSource dataSource)
throws SQLException {
HibernateJpaVendorAdapter jpaVendorAdapter = new HibernateJpaVendorAdapter();
jpaVendorAdapter.setGenerateDdl(true);
LocalContainerEntityManagerFactoryBean bean = new LocalContainerEntityManagerFactoryBean();
bean.setJpaVendorAdapter(jpaVendorAdapter);
bean.setPackagesToScan(Config.class.getPackage().getName());
bean.setDataSource(dataSource);
return bean;
}
示例7: entityManagerFactory
import org.springframework.orm.jpa.AbstractEntityManagerFactoryBean; //导入依赖的package包/类
@Bean
public AbstractEntityManagerFactoryBean entityManagerFactory() {
Map<String, Object> jpaProperties = new HashMap<>();
log.info("Setting up entity manager factory, with Hibernate properties ...");
LocalContainerEntityManagerFactoryBean localContainerEntityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
localContainerEntityManagerFactoryBean.setPackagesToScan("za.org.grassroot.core");
// localContainerEntityManagerFactoryBean.setJpaPropertyMap(jpaProperties);
localContainerEntityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
localContainerEntityManagerFactoryBean.setDataSource(dataSource());
return localContainerEntityManagerFactoryBean;
}
示例8: entityManagerFactory
import org.springframework.orm.jpa.AbstractEntityManagerFactoryBean; //导入依赖的package包/类
@Bean
public AbstractEntityManagerFactoryBean entityManagerFactory() {
LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
emf.setDataSource(dataSource());
emf.setPackagesToScan("papadie.model");
emf.setPersistenceProvider(new HibernatePersistence());
emf.getJpaPropertyMap().put("hibernate.hbm2ddl.auto", "create-drop");
emf.getJpaPropertyMap().put("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
emf.getJpaPropertyMap().put("hibernate.show_sql", "true");
emf.afterPropertiesSet();
return emf;
}
示例9: entityManagerFactory
import org.springframework.orm.jpa.AbstractEntityManagerFactoryBean; //导入依赖的package包/类
@Bean
public AbstractEntityManagerFactoryBean entityManagerFactory(EntityManagerFactoryBuilder builder, DataSource dataSource) {
return builder.dataSource(dataSource).packages("com.mrpehlivan").build();
}
示例10: JpaModule
import org.springframework.orm.jpa.AbstractEntityManagerFactoryBean; //导入依赖的package包/类
/**
* Constructor for JpaModule.
*/
public JpaModule() {
super();
// Make sure recent version spring ORM module is in the classpath
AbstractEntityManagerFactoryBean.class.getName();
}
示例11: isCustomConfigMethod
import org.springframework.orm.jpa.AbstractEntityManagerFactoryBean; //导入依赖的package包/类
protected boolean isCustomConfigMethod(Method annotatedMethod) {
return annotatedMethod.getReturnType().toString().equals("void")
&& annotatedMethod.getParameterTypes().length == 1
&& AbstractEntityManagerFactoryBean.class.isAssignableFrom(annotatedMethod.getParameterTypes()[0]);
}
示例12: getConfiguredOrmPersistenceUnit
import org.springframework.orm.jpa.AbstractEntityManagerFactoryBean; //导入依赖的package包/类
public ConfiguredOrmPersistenceUnit<EntityManagerFactory, Object> getConfiguredOrmPersistenceUnit(Object testObject, JpaConfig entityManagerConfig) {
AbstractEntityManagerFactoryBean factoryBean = createEntityManagerFactoryBean(testObject, entityManagerConfig);
EntityManagerFactory entityManagerFactory = factoryBean.getObject();
Object providerSpecificConfigurationObject = getJpaProviderSupport().getProviderSpecificConfigurationObject(factoryBean.getPersistenceProvider());
return new ConfiguredOrmPersistenceUnit<EntityManagerFactory, Object>(entityManagerFactory, providerSpecificConfigurationObject);
}
示例13: EntityManagerFactoryDependsOnPostProcessor
import org.springframework.orm.jpa.AbstractEntityManagerFactoryBean; //导入依赖的package包/类
public EntityManagerFactoryDependsOnPostProcessor(String... dependsOn) {
super(EntityManagerFactory.class, AbstractEntityManagerFactoryBean.class,
dependsOn);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:5,代码来源:EntityManagerFactoryDependsOnPostProcessor.java
示例14: sessionFactory
import org.springframework.orm.jpa.AbstractEntityManagerFactoryBean; //导入依赖的package包/类
@Bean
public SessionFactory sessionFactory(AbstractEntityManagerFactoryBean entityManagerFactory)
throws SQLException {
return ((HibernateEntityManagerFactory) entityManagerFactory.getObject()).getSessionFactory();
}
示例15: main
import org.springframework.orm.jpa.AbstractEntityManagerFactoryBean; //导入依赖的package包/类
public static void main(String[] args) {
boolean drop = false;
boolean create = false;
String outFile = null;
String delimiter = "";
String activeSpringProfile = null;
String dataAccessApplicationContextConfigClassPath = null;
for (int i = 0; i < args.length; i++) {
if (args[i].startsWith("--")) {
if (args[i].equals("--drop")) {
drop = true;
} else if (args[i].equals("--create")) {
create = true;
} else if (args[i].startsWith("--output=")) {
outFile = args[i].substring(9);
} else if (args[i].startsWith("--delimiter=")) {
delimiter = args[i].substring(12);
} else if (args[i].startsWith("--activeSpringProfile=")) {
activeSpringProfile = args[i].substring(22);
} else if (args[i].startsWith("--dataAccessApplicationContextConfigClassPath=")) {
dataAccessApplicationContextConfigClassPath = args[i].substring(46);
}
}
}
Formatter formatter = FormatStyle.DDL.getFormatter();
GenericXmlApplicationContext context = new GenericXmlApplicationContext();
if (activeSpringProfile != null) {
context.getEnvironment().setActiveProfiles(activeSpringProfile);
}
context.load(dataAccessApplicationContextConfigClassPath);
context.refresh();
AbstractEntityManagerFactoryBean bean = context
.getBean(AbstractEntityManagerFactoryBean.class);
Ejb3Configuration jpaConfiguration = new Ejb3Configuration().configure(
bean.getPersistenceUnitInfo(), bean.getJpaPropertyMap());
SchemaExporter.export(jpaConfiguration, drop, create, outFile, delimiter, formatter);
context.close();
}