当前位置: 首页>>代码示例>>Java>>正文


Java AbstractEntityManagerFactoryBean类代码示例

本文整理汇总了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;
  }
 
开发者ID:linux-china,项目名称:unitils,代码行数:30,代码来源:JpaEntityManagerFactoryLoader.java

示例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);
}
 
开发者ID:linux-china,项目名称:unitils,代码行数:8,代码来源:JpaSpringSupport.java

示例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();
}
 
开发者ID:linux-china,项目名称:unitils,代码行数:15,代码来源:JpaSpringSupport.java

示例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;
}
 
开发者ID:darrachequesne,项目名称:spring-data-jpa-datatables,代码行数:15,代码来源:Config.java

示例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;
}
 
开发者ID:grassrootza,项目名称:grassroot-platform,代码行数:14,代码来源:StandaloneDatabaseConfig.java

示例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;
}
 
开发者ID:ieugen,项目名称:angular-ui,代码行数:14,代码来源:AppConfig.java

示例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();
}
 
开发者ID:mrpehlivan,项目名称:SpringBootCRUD,代码行数:5,代码来源:DatabaseConfiguration.java

示例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();
}
 
开发者ID:linux-china,项目名称:unitils,代码行数:9,代码来源:JpaModule.java

示例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]);
}
 
开发者ID:linux-china,项目名称:unitils,代码行数:6,代码来源:JpaAnnotationConfigLoader.java

示例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);
}
 
开发者ID:linux-china,项目名称:unitils,代码行数:7,代码来源:JpaEntityManagerFactoryLoader.java

示例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();
}
 
开发者ID:darrachequesne,项目名称:spring-data-jpa-datatables,代码行数:6,代码来源:Config.java

示例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();
}
 
开发者ID:tlin-fei,项目名称:ds4p,代码行数:49,代码来源:SpringEntityManagerFactoryBeanConfigSchemaExporter.java


注:本文中的org.springframework.orm.jpa.AbstractEntityManagerFactoryBean类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。