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


Java LocalSessionFactoryBean.setPackagesToScan方法代碼示例

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


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

示例1: afterPropertiesSet

import org.springframework.orm.hibernate4.LocalSessionFactoryBean; //導入方法依賴的package包/類
public void afterPropertiesSet() throws IOException {
    long startTime = System.currentTimeMillis();

    // init SessionFactoryWrapper
    sessionFactoryWrapper = new SessionFactoryWrapper();

    try {
        // init LocalSessionFactoryBean
        localSessionFactoryBean = new LocalSessionFactoryBean();
        localSessionFactoryBean.setDataSource(dataSource);
        localSessionFactoryBean.setHibernateProperties(hibernateProperties);
        localSessionFactoryBean.setPackagesToScan(packagesToScan);

        localSessionFactoryBean.afterPropertiesSet();

        SessionFactory sessionFactory = localSessionFactoryBean.getObject();
        sessionFactoryWrapper.setSessionFactory(sessionFactory);
    } catch (Exception ex) {
        logger.error(ex.getMessage(), ex);
    }

    long endTime = System.currentTimeMillis();
    logger.info("hibernate init cost {} ms", (endTime - startTime));
}
 
開發者ID:zhaojunfei,項目名稱:lemon,代碼行數:25,代碼來源:RecoverableSessionFactoryBean.java

示例2: sessionFactoryBeanTest

import org.springframework.orm.hibernate4.LocalSessionFactoryBean; //導入方法依賴的package包/類
@Bean
@Profile("test")
public SessionFactory sessionFactoryBeanTest(DataSource dataSource) {
    try {
        LocalSessionFactoryBean lsfb = new LocalSessionFactoryBean();
        lsfb.setDataSource(dataSource);
        lsfb.setPackagesToScan("com.opteral.springsms.model");
        Properties props = new Properties();
        props.setProperty("dialect", "org.hibernate.dialect.H2Dialect");
        lsfb.setHibernateProperties(props);
        lsfb.afterPropertiesSet();
        SessionFactory object = lsfb.getObject();
        return object;
    } catch (IOException e) {
        return null;
    }
}
 
開發者ID:amalio,項目名稱:spring-json-sms-gateway,代碼行數:18,代碼來源:DataConfig.java

示例3: sessionFactoryBean

import org.springframework.orm.hibernate4.LocalSessionFactoryBean; //導入方法依賴的package包/類
@Bean
@Profile("default")
public SessionFactory sessionFactoryBean(DataSource dataSource) {
    try {
        LocalSessionFactoryBean lsfb = new LocalSessionFactoryBean();
        lsfb.setDataSource(dataSource);
        lsfb.setPackagesToScan("com.opteral.springsms.model");
        Properties props = new Properties();
        props.setProperty("dialect", "org.hibernate.dialect.MySQLDialect");
        lsfb.setHibernateProperties(props);
        lsfb.afterPropertiesSet();
        SessionFactory object = lsfb.getObject();
        return object;
    } catch (IOException e) {
        return null;
    }
}
 
開發者ID:amalio,項目名稱:spring-json-sms-gateway,代碼行數:18,代碼來源:DataConfig.java

示例4: sessionFactory

import org.springframework.orm.hibernate4.LocalSessionFactoryBean; //導入方法依賴的package包/類
/**
 * 
 * This setups the session factory
 */
@Bean
public LocalSessionFactoryBean sessionFactory(Environment environment,
		DataSource dataSource) {

	/**
	 * 
	 * Getting packageOfModelBean from package of message bean
	 * 
	 */

	LocalSessionFactoryBean factoryBean = new LocalSessionFactoryBean();

	factoryBean.setDataSource(dataSource);
	factoryBean
			.setHibernateProperties(buildHibernateProperties(environment));
	factoryBean.setPackagesToScan(packagesToScan);
	return factoryBean;
}
 
開發者ID:DevOpsDistilled,項目名稱:OpERP,代碼行數:23,代碼來源:DbTestContext.java

示例5: sessionFactory

import org.springframework.orm.hibernate4.LocalSessionFactoryBean; //導入方法依賴的package包/類
@Bean
    public LocalSessionFactoryBean sessionFactory() {
        LocalSessionFactoryBean sessionFactoryBean = new LocalSessionFactoryBean();
        sessionFactoryBean.setDataSource(dataSource());
        sessionFactoryBean.setPackagesToScan(ENTITYMANAGER_PACKAGES_TO_SCAN);
        Properties hibernateProperties = new Properties();
        hibernateProperties.put("hibernate.dialect", HIBERNATE_DIALECT);
        hibernateProperties.put("hibernate.show_sql", HIBERNATE_SHOW_SQL);
//        hibernateProperties.put("hibernate.hbm2ddl.auto", HIBERNATE_HBM2DDL_AUTO);
        sessionFactoryBean.setHibernateProperties(hibernateProperties);

        return sessionFactoryBean;
    }
 
開發者ID:aollio,項目名稱:school-express-delivery,代碼行數:14,代碼來源:ServerDataSourceConfig.java

示例6: sessionFactory

import org.springframework.orm.hibernate4.LocalSessionFactoryBean; //導入方法依賴的package包/類
@Bean
public LocalSessionFactoryBean sessionFactory() {
    LocalSessionFactoryBean sessionFactoryBean = new LocalSessionFactoryBean();
    sessionFactoryBean.setDataSource(dataSource());
    sessionFactoryBean.setPackagesToScan(ENTITYMANAGER_PACKAGES_TO_SCAN);
    Properties hibernateProperties = new Properties();
    hibernateProperties.put("hibernate.dialect", HIBERNATE_DIALECT);
    hibernateProperties.put("hibernate.show_sql", HIBERNATE_SHOW_SQL);
    hibernateProperties.put("hibernate.hbm2ddl.auto", HIBERNATE_HBM2DDL_AUTO);
    sessionFactoryBean.setHibernateProperties(hibernateProperties);

    return sessionFactoryBean;
}
 
開發者ID:aollio,項目名稱:school-express-delivery,代碼行數:14,代碼來源:DataSourceConfig.java

示例7: sessionFactory

import org.springframework.orm.hibernate4.LocalSessionFactoryBean; //導入方法依賴的package包/類
@Bean
public LocalSessionFactoryBean sessionFactory(){
    LocalSessionFactoryBean sessionFactoryBean = new LocalSessionFactoryBean();
    sessionFactoryBean.setDataSource(dataSource());
    sessionFactoryBean.setPackagesToScan(environment.getProperty(PROPERTY_NAME_ENTITYMANAGER_PACKAGES_TO_SCAN));
    sessionFactoryBean.setHibernateProperties(hibProperties());
    sessionFactoryBean.setEntityInterceptor(preInsertUpdateInterceptor());
    return sessionFactoryBean;
}
 
開發者ID:Witerium,項目名稱:stuffEngine,代碼行數:10,代碼來源:DAOConfig.java

示例8: sessionFactory

import org.springframework.orm.hibernate4.LocalSessionFactoryBean; //導入方法依賴的package包/類
/**
 * enable @Bean annotation if you want to use hibernate instead of spring data JPA repositories
 *
 * @param dataSource
 * @return LocalSessionFactoryBean
 */
// @Bean
public LocalSessionFactoryBean sessionFactory(DataSource dataSource) {
    final LocalSessionFactoryBean sfb = new LocalSessionFactoryBean();
    sfb.setDataSource(dataSource);
    sfb.setPackagesToScan(new String[] { "com.tvajjala.persistence.domain" });
    final Properties props = new Properties();
    props.setProperty("dialect", "org.hibernate.dialect.MySQL5InnoDBDialect");
    sfb.setHibernateProperties(props);
    return sfb;
}
 
開發者ID:tvajjala,項目名稱:interview-preparation,代碼行數:17,代碼來源:DBConfig.java

示例9: sessionFactory

import org.springframework.orm.hibernate4.LocalSessionFactoryBean; //導入方法依賴的package包/類
@Bean
public LocalSessionFactoryBean sessionFactory() {
    LocalSessionFactoryBean sessionFactoryBean = new LocalSessionFactoryBean();
    sessionFactoryBean.setDataSource(dataSource());
    sessionFactoryBean.setPackagesToScan("com.espark.adarsh");
    Properties hibernateProperties = new Properties();
    hibernateProperties.put("hibernate.dialect", HIBERNATE_DIALECT);
    hibernateProperties.put("hibernate.show_sql", HIBERNATE_SHOW_SQL);
    hibernateProperties.put("hibernate.hbm2ddl.auto", HIBERNATE_HBM2DDL_AUTO);
    sessionFactoryBean.setHibernateProperties(hibernateProperties);

    return sessionFactoryBean;
}
 
開發者ID:adarshkumarsingh83,項目名稱:spring_boot,代碼行數:14,代碼來源:PersistenceConfigurations.java

示例10: sessionFactory

import org.springframework.orm.hibernate4.LocalSessionFactoryBean; //導入方法依賴的package包/類
@Bean
public LocalSessionFactoryBean sessionFactory() {
    LocalSessionFactoryBean localSessionFactoryBean = new LocalSessionFactoryBean();
    localSessionFactoryBean.setDataSource(dataSource);
    localSessionFactoryBean.setPackagesToScan(PACKAGES_TO_SCAN);
    Properties hibernateProperties = new Properties();
    hibernateProperties.setProperty("hibernate.dialect", this.dialect);
    hibernateProperties.setProperty("hibernate.show_sql", Boolean.TRUE.toString());
    localSessionFactoryBean.setHibernateProperties(hibernateProperties);
    return localSessionFactoryBean;
}
 
開發者ID:belchan,項目名稱:imageboard,代碼行數:12,代碼來源:Config.java

示例11: sessionFactory

import org.springframework.orm.hibernate4.LocalSessionFactoryBean; //導入方法依賴的package包/類
@DependsOn("createFunctionInitializer")
@Bean
public LocalSessionFactoryBean sessionFactory(final DataSource dataSource) {
    final LocalSessionFactoryBean sessionFactoryBean = new LocalSessionFactoryBean();
    sessionFactoryBean.setDataSource(dataSource);
    sessionFactoryBean.setHibernateProperties(hibernateProperties());
    sessionFactoryBean.setPackagesToScan(hibernatePackagesToScan());
    Optional<String> schemaName = SingularProperties.getOpt(CUSTOM_SCHEMA_NAME);
    if (schemaName.isPresent()) {
        sessionFactoryBean.setEntityInterceptor(new SingularEntityInterceptor());
        getLogger().info("Utilizando schema customizado: {}", schemaName.get());
    }
    return sessionFactoryBean;
}
 
開發者ID:opensingular,項目名稱:singular-server,代碼行數:15,代碼來源:SingularDefaultPersistenceConfiguration.java

示例12: sessionFactory

import org.springframework.orm.hibernate4.LocalSessionFactoryBean; //導入方法依賴的package包/類
@Bean
public LocalSessionFactoryBean sessionFactory() {
	LocalSessionFactoryBean sessionFactoryBean = new LocalSessionFactoryBean();
	sessionFactoryBean.setDataSource(dataSource());
	sessionFactoryBean.setPackagesToScan("com.servinglynk.hmis.warehouse.model");
	sessionFactoryBean.setHibernateProperties(hibProperties());
	return sessionFactoryBean;
}
 
開發者ID:hserv,項目名稱:coordinated-entry,代碼行數:9,代碼來源:DatabaseConfig.java

示例13: sessionFactory

import org.springframework.orm.hibernate4.LocalSessionFactoryBean; //導入方法依賴的package包/類
@Bean
@Autowired
public LocalSessionFactoryBean sessionFactory(DataSource dataSource) {
	Properties properties = new Properties();
	properties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect"));
	properties.setProperty("hibernate.show_sql", env.getProperty("hibernate.show_sql"));
	properties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl-auto"));
	LocalSessionFactoryBean localSessionFactoryBean = new LocalSessionFactoryBean();
	localSessionFactoryBean.setDataSource(dataSource);
	localSessionFactoryBean.setHibernateProperties(properties);
	localSessionFactoryBean.setPackagesToScan(new String[] { "com.maellakioa.models" });
	return localSessionFactoryBean;
}
 
開發者ID:karabill,項目名稱:maellak_spring_example,代碼行數:14,代碼來源:MyConfiguration.java

示例14: sessionFactory

import org.springframework.orm.hibernate4.LocalSessionFactoryBean; //導入方法依賴的package包/類
@Bean
public LocalSessionFactoryBean sessionFactory() {
    LocalSessionFactoryBean sessionFactoryBean = new LocalSessionFactoryBean();
    sessionFactoryBean.setDataSource(dataSource());
    sessionFactoryBean.setPackagesToScan(env.getRequiredProperty(PROPERTY_NAME_ENTITYMANAGER_PACKAGES_TO_SCAN));
    sessionFactoryBean.setHibernateProperties(hibProperties());
    
    
    return sessionFactoryBean;
}
 
開發者ID:thecodinglive,項目名稱:hanbit-gradle-book-example,代碼行數:11,代碼來源:DbConfig.java

示例15: sessionFactory

import org.springframework.orm.hibernate4.LocalSessionFactoryBean; //導入方法依賴的package包/類
@Bean
@ConditionalOnBean(name = "dataSource")
public LocalSessionFactoryBean sessionFactory() {
	LocalSessionFactoryBean sessionFactoryBean = new LocalSessionFactoryBean();
	sessionFactoryBean.setDataSource(this.dataSource());
	sessionFactoryBean.setJtaTransactionManager(txManager());
	sessionFactoryBean.setPackagesToScan(this.getHibernate().getPackagesToScan());
	Properties hibernateProperties = new Properties();
	hibernateProperties.put("hibernate.dialect", this.getHibernate().getDialect());
	hibernateProperties.put("hibernate.show_sql", this.getHibernate().isShowsql());
	hibernateProperties.put("hibernate.format_sql", this.getHibernate().isFormatsql());
	hibernateProperties.put("hibernate.hbm2ddl.auto", this.getHibernate().getHbm2ddlauto());
	
	hibernateProperties.put("hibernate.connection.pool_size", this.getHibernate().getConnection_pool_size());
	//Spring + Bitronix manages the transaction by default!
	//sessionFactoryBean.setJtaTransactionManager(jtaTransactionManager);
	//org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory
	//org.hibernate.engine.transaction.internal.jta.JtaTransactionFactory
	hibernateProperties.put("hibernate.jndi.class", "bitronix.tm.jndi.BitronixInitialContextFactory");
	hibernateProperties.put("hibernate.transaction.factory_class", "org.hibernate.engine.transaction.internal.jta.JtaTransactionFactory");
	hibernateProperties.put("hibernate.transaction.jta.platform", "org.hibernate.service.jta.platform.internal.BitronixJtaPlatform");
	hibernateProperties.put("hibernate.current_session_context_class", "jta"); //or thread binding.
	
	hibernateProperties.put("hibernate.cache.provider_class", this.getHibernate().getCache_provider_class());
	hibernateProperties.put("hibernate.enable_lazy_load_no_trans", this.getHibernate().isEnable_lazy_load_no_trans());
	hibernateProperties.put("hibernate.generate_statistics", this.getHibernate().isGenerate_statistics());
	hibernateProperties.put("hibernate.connection.autoReconnet", this.getHibernate().isAutoReconnet());
	hibernateProperties.put("hibernate.connection.autoReconnectForPools", this.getHibernate().isAutoReconnectForPools());
	hibernateProperties.put("hibernate.connection.is-connection-validation-required", this.getHibernate().isIsconnectionvalidationrequired());
	hibernateProperties.put("hibernate.connection.validationQuery", this.getHibernate().getValidationQuery());
	
	sessionFactoryBean.setHibernateProperties(hibernateProperties);
	if (this.getHbmRoot() != null && this.getHbmRoot().length() > 0) {
		sessionFactoryBean.setMappingDirectoryLocations(new FileSystemResource(this.getHbmRoot()));
	}
	return sessionFactoryBean;
}
 
開發者ID:shaolinwu,項目名稱:uimaster,代碼行數:38,代碼來源:PersistentConfig.java


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