當前位置: 首頁>>代碼示例>>Java>>正文


Java LocalContainerEntityManagerFactoryBean.setPackagesToScan方法代碼示例

本文整理匯總了Java中org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.setPackagesToScan方法的典型用法代碼示例。如果您正苦於以下問題:Java LocalContainerEntityManagerFactoryBean.setPackagesToScan方法的具體用法?Java LocalContainerEntityManagerFactoryBean.setPackagesToScan怎麽用?Java LocalContainerEntityManagerFactoryBean.setPackagesToScan使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean的用法示例。


在下文中一共展示了LocalContainerEntityManagerFactoryBean.setPackagesToScan方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: newEntityManagerFactory

import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //導入方法依賴的package包/類
public static EntityManagerFactory newEntityManagerFactory(DataSource dataSource, Class<?> ... entityPackages){
	HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
	vendorAdapter.setGenerateDdl(true);

	BasicDataSource basicDataSource = (BasicDataSource)dataSource;
	Database jpaDatabase = DatabaseType.findTypeByJdbcUrl(basicDataSource.getUrl()).getJpaDatabase();
	vendorAdapter.setDatabase(jpaDatabase);

	HashMap<String, Object> properties = new HashMap<String, Object>();
	//properties.put("hibernate.dialect", "org.hibernate.dialect.MySQL5InnoDBDialect");

	LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
	factory.setJpaVendorAdapter(vendorAdapter);
	//import @Entity classes
	factory.setPackagesToScan(Arrays.stream(entityPackages).map(thing -> thing.getPackage().getName()).toArray(String[]::new));
	//factory.setPersistenceUnitName("jproject");
	factory.setDataSource(dataSource);
	factory.setJpaPropertyMap(properties);
	factory.afterPropertiesSet();

	return factory.getObject();
}
 
開發者ID:profullstack,項目名稱:spring-seed,代碼行數:23,代碼來源:JpaBuilderUtil.java

示例2: entityManagerFactory

import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //導入方法依賴的package包/類
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource());
    em.setPackagesToScan("com.tickets.business.entities");

    final Properties hibernateProperties = new Properties();
    hibernateProperties.setProperty("hibernate.hbm2ddl.auto", "update");
    hibernateProperties.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect");
    em.setJpaProperties(hibernateProperties);
    
    final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    em.setJpaVendorAdapter(vendorAdapter);

    return em;
}
 
開發者ID:sysuOTS,項目名稱:TicketServer,代碼行數:17,代碼來源:SpringBusinessConfig.java

示例3: entityManagerFactory

import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //導入方法依賴的package包/類
@Bean
public FactoryBean<EntityManagerFactory> entityManagerFactory() {
	LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
	emf.setDataSource(dataSource());
	emf.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
	emf.setPackagesToScan(TestJpaDomain.class.getPackage().getName());
	emf.setPersistenceUnitName("test");
	return emf;
}
 
開發者ID:holon-platform,項目名稱:holon-datastore-jpa,代碼行數:10,代碼來源:TestBase.java

示例4: entityManagerFactory

import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //導入方法依賴的package包/類
@Bean
public EntityManagerFactory entityManagerFactory(DataSource dataSource) {
    final Database database = Database.valueOf(vendor.toUpperCase());
    /*
    final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setShowSql(showSql);
    vendorAdapter.setGenerateDdl(showDdl);
    vendorAdapter.setDatabase(database);
    */

    final LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setPersistenceUnitName("CCRI_PU");
   // factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan("uk.nhs.careconnect.ri.entity");
    factory.setDataSource(dataSource);
    factory.setPersistenceProvider(new HibernatePersistenceProvider());
    factory.setJpaProperties(jpaProperties());
    factory.afterPropertiesSet();


    return factory.getObject();
}
 
開發者ID:nhsconnect,項目名稱:careconnect-reference-implementation,代碼行數:23,代碼來源:DataSourceConfig.java

示例5: entityManagerFactory

import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //導入方法依賴的package包/類
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource,
    MultiTenantConnectionProvider multiTenantConnectionProviderImpl,
    CurrentTenantIdentifierResolver currentTenantIdentifierResolverImpl) {
    Map<String, Object> properties = new HashMap<>();
    properties.putAll(jpaProperties.getHibernateProperties(dataSource));
    properties.put(org.hibernate.cfg.Environment.MULTI_TENANT, MultiTenancyStrategy.SCHEMA);
    properties
        .put(org.hibernate.cfg.Environment.MULTI_TENANT_CONNECTION_PROVIDER, multiTenantConnectionProviderImpl);
    properties
        .put(org.hibernate.cfg.Environment.MULTI_TENANT_IDENTIFIER_RESOLVER, currentTenantIdentifierResolverImpl);

    LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource);
    em.setPackagesToScan(JPA_PACKAGES);
    em.setJpaVendorAdapter(jpaVendorAdapter());
    em.setJpaPropertyMap(properties);
    return em;
}
 
開發者ID:xm-online,項目名稱:xm-ms-dashboard,代碼行數:20,代碼來源:DatabaseConfiguration.java

示例6: entityManagerFactory

import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //導入方法依賴的package包/類
@Bean(EntityManagerFactoryBeanName)
public LocalContainerEntityManagerFactoryBean entityManagerFactory(
        @Qualifier(DataSourceBeanName) DataSource dataSource,
        @Qualifier(JpaVendorAdapterBeanName) JpaVendorAdapter vendorAdapter) {

    LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
    entityManagerFactoryBean.setDataSource(dataSource);
    entityManagerFactoryBean.setJpaVendorAdapter(vendorAdapter);
    entityManagerFactoryBean.setJpaDialect(new HibernateJpaDialect());
    entityManagerFactoryBean.setPackagesToScan(Organization.class.getPackage().getName());
    entityManagerFactoryBean.setPersistenceUnitName("mysqlsource2");
    entityManagerFactoryBean.afterPropertiesSet();

    return entityManagerFactoryBean;
}
 
開發者ID:omacarena,項目名稱:only-short-poc,代碼行數:16,代碼來源:MySqlSource2Config.java

示例7: entityManagerFactory

import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //導入方法依賴的package包/類
@Bean
public FactoryBean<EntityManagerFactory> entityManagerFactory(DataSource dataSource) {
	LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
	emf.setDataSource(dataSource);
	emf.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
	emf.setPackagesToScan("com.exmaple.test.entities");
	return emf;
}
 
開發者ID:holon-platform,項目名稱:holon-datastore-jpa,代碼行數:9,代碼來源:ExampleJpaDatastoreSpring.java

示例8: getEntityManager

import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //導入方法依賴的package包/類
@Bean(name="entityManagerFactory")
public LocalContainerEntityManagerFactoryBean getEntityManager(){
    // класса фабрики реализующей интерфейс FactoryBean<EntityManagerFactory>
    LocalContainerEntityManagerFactoryBean factory =
        new LocalContainerEntityManagerFactoryBean();

    // источник подключения
    factory.setDataSource(getDataSource());

    // адаптера для конкретной реализации JPA, 
    // указывает, какая библиотека будет использоваться в качестве постовщика
    factory.setJpaVendorAdapter(new HibernateJpaVendorAdapter());

    // указание пакета в котором находятся классы-сущности
    factory.setPackagesToScan("spring.domain");

    //создание свойств для настройки Hibernate
    Properties jpaProperties = new Properties();

    // диалект базы данных,необходимо для генерации запросов Hibernate к БД
    jpaProperties.put("hibernate.dialect", "org.hibernate.dialect.SQLiteDialect");

    // максимальная глубины связи(будет рассмотрено в след. уроке)
    jpaProperties.put("hibernate.max_fetch_depth", 3);

    // максимальное число строк, возвращаемых за один запрос из БД
    jpaProperties.put("hibernate.jdbc.fetch_size", 50);

    // максимальное число запросов при использовании пакетных операций
    jpaProperties.put("hibernate.jdbc.batch_size", 10);

    // включает логгирование
    jpaProperties.put("hibernate.show_sql", true);

    factory.setJpaProperties(jpaProperties);
    return factory;
}
 
開發者ID:biblelamp,項目名稱:JavaEE,代碼行數:38,代碼來源:AppConfig.java

示例9: entityManagerFactory

import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //導入方法依賴的package包/類
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
	LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
	em.setDataSource(dataSource());
	em.setPackagesToScan(new String[] { "com.iisigroup.domain" });

	JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
	em.setJpaVendorAdapter(vendorAdapter);
	em.setJpaProperties(hibernateProperties());

	return em;
}
 
開發者ID:lf23617358,項目名稱:training-sample,代碼行數:13,代碼來源:AppConfig.java

示例10: entityManagerFactory

import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //導入方法依賴的package包/類
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
	LocalContainerEntityManagerFactoryBean retVal = new LocalContainerEntityManagerFactoryBean();
	//retVal.setPersistenceUnitManager(persistenceUnitManager());
	retVal.setMappingResources(orm);
	retVal.setPackagesToScan("org.partners.usciitg_prep.terminology.jpa");
	retVal.setPersistenceUnitName(persistenceUnitName);
	retVal.setDataSource(dataSource());
	retVal.setPersistenceProvider(new HibernatePersistenceProvider());		
	retVal.setJpaProperties(jpaProperties());
	return retVal;
}
 
開發者ID:Discovery-Research-Network-SCCM,項目名稱:FHIR-CQL-ODM-service,代碼行數:13,代碼來源:FhirServerTestConfigDstu3.java

示例11: entityManagerFactory

import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //導入方法依賴的package包/類
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() throws NamingException {
	LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();
	factoryBean.setDataSource(dataSource());
	factoryBean.setPackagesToScan(new String[] { "com.docker.atsea.model" });
	factoryBean.setJpaVendorAdapter(jpaVendorAdapter());
	factoryBean.setJpaProperties(jpaProperties());
	return factoryBean;
}
 
開發者ID:dockersamples,項目名稱:atsea-sample-shop-app,代碼行數:10,代碼來源:JpaConfiguration.java

示例12: entityManagerFactory

import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //導入方法依賴的package包/類
@Bean()
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
	LocalContainerEntityManagerFactoryBean retVal = new LocalContainerEntityManagerFactoryBean();
	retVal.setPersistenceUnitName("HAPI_PU");
	retVal.setDataSource(dataSource());
	retVal.setPackagesToScan("ca.uhn.fhir.jpa.entity");
	retVal.setPersistenceProvider(new HibernatePersistenceProvider());
	retVal.setJpaProperties(jpaProperties());
	return retVal;
}
 
開發者ID:gerard-bisama,項目名稱:DHIS2-fhir-lab-app,代碼行數:11,代碼來源:FhirServerConfig.java

示例13: archiveringEntityManagerFactory

import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //導入方法依賴的package包/類
/**
 * @return entity manager factory (archivering; alleen lezen)
 */
@Bean(name = ENTITY_MANAGER_ARCHIVERING)
@DependsOn(TRANSACTION_MANAGER)
public LocalContainerEntityManagerFactoryBean archiveringEntityManagerFactory() {
    final LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
    entityManagerFactoryBean.setDataSource(archiveringDataSource());
    entityManagerFactoryBean.setPersistenceUnitName(PERSISTENCE_UNIT_ARCHIVERING);
    entityManagerFactoryBean.setPersistenceProviderClass(HibernatePersistenceProvider.class);
    entityManagerFactoryBean.setPackagesToScan(PACKAGE_USERTYPES, PACKAGE_STAMGEGEVEN_ENTITY, PACKAGE_BEHEER_VIEW);

    entityManagerFactoryBean.setJpaProperties(hibernateProperties());

    return entityManagerFactoryBean;
}
 
開發者ID:MinBZK,項目名稱:OperatieBRP,代碼行數:17,代碼來源:RepositoryConfiguratie.java

示例14: entityManagerFactory1

import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //導入方法依賴的package包/類
@Bean
@Primary
public FactoryBean<EntityManagerFactory> entityManagerFactory1(@Qualifier("one") DataSource dataSource) {
	LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
	emf.setDataSource(dataSource);
	HibernateJpaVendorAdapter va = new HibernateJpaVendorAdapter();
	va.setShowSql(true);
	emf.setJpaVendorAdapter(va);
	emf.setPackagesToScan(TestJpaDomain1.class.getPackage().getName());
	emf.setPersistenceUnitName("one");
	return emf;
}
 
開發者ID:holon-platform,項目名稱:holon-datastore-jpa,代碼行數:13,代碼來源:TestEnableDatastoreMulti.java

示例15: entityManagerFactory

import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //導入方法依賴的package包/類
@Bean
public EntityManagerFactory entityManagerFactory() {
    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setDatabase(Database.POSTGRESQL);
    vendorAdapter.setGenerateDdl(generateDDL);
    vendorAdapter.setShowSql(true);

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan("ro.dutylabs.mpp.core.model");
    factory.setDataSource(dataSource());
    factory.afterPropertiesSet();
    return factory.getObject();
}
 
開發者ID:rusucosmin,項目名稱:exampp,代碼行數:15,代碼來源:JPAConfig.java


注:本文中的org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.setPackagesToScan方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。