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


Java LocalSessionFactoryBean.setDataSource方法代码示例

本文整理汇总了Java中org.springframework.orm.hibernate5.LocalSessionFactoryBean.setDataSource方法的典型用法代码示例。如果您正苦于以下问题:Java LocalSessionFactoryBean.setDataSource方法的具体用法?Java LocalSessionFactoryBean.setDataSource怎么用?Java LocalSessionFactoryBean.setDataSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.orm.hibernate5.LocalSessionFactoryBean的用法示例。


在下文中一共展示了LocalSessionFactoryBean.setDataSource方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createSessionFactoryBean

import org.springframework.orm.hibernate5.LocalSessionFactoryBean; //导入方法依赖的package包/类
protected LocalSessionFactoryBean createSessionFactoryBean() {

		LocalSessionFactoryBean factoryBean = new LocalSessionFactoryBean();
		factoryBean.setDataSource(this.dataSourceConfig.dataSource());

		if (StringUtil.isEmpty(this.propertiesConfig.hibernateDialect())) {
			throw new IllegalStateException("hibernateDialect is required");
		}

		factoryBean.getHibernateProperties().setProperty(AvailableSettings.DIALECT,
				this.propertiesConfig.hibernateDialect());

		if (!ArrayUtil.isEmpty(this.propertiesConfig.hibernateMappingLocations())) {
			factoryBean
					.setMappingLocations(this.propertiesConfig.hibernateMappingLocations());
		}

		return factoryBean;

	}
 
开发者ID:RJBTechnology,项目名称:rjb-blog-multitenancy,代码行数:21,代码来源:HibernateConfig.java

示例2: createSessionFactory

import org.springframework.orm.hibernate5.LocalSessionFactoryBean; //导入方法依赖的package包/类
private SessionFactory createSessionFactory(Properties properties, DataSource dataSource, String[] packagesToScan) {
    if (dataSource == null)
        throw new NullPointerException("数据源不存在,无法初始化Hibernate环境!");

    LocalSessionFactoryBean sessionFactoryBean = new LocalSessionFactoryBean();
    sessionFactoryBean.setHibernateProperties(properties);
    sessionFactoryBean.setDataSource(dataSource);
    sessionFactoryBean.setPackagesToScan(packagesToScan);
    try {
        sessionFactoryBean.afterPropertiesSet();

        return sessionFactoryBean.getObject();
    } catch (IOException e) {
        logger.warn(e, "初始化Hibernate环境[{}]时发生异常!", converter.toString(packagesToScan));

        return null;
    }
}
 
开发者ID:heisedebaise,项目名称:tephra,代码行数:19,代码来源:SessionFactoryImpl.java

示例3: sessionFactoryBean

import org.springframework.orm.hibernate5.LocalSessionFactoryBean; //导入方法依赖的package包/类
@Bean
public LocalSessionFactoryBean sessionFactoryBean() {
    LocalSessionFactoryBean bean = new LocalSessionFactoryBean();
    Properties hibernateProperties = new Properties();
    hibernateProperties.setProperty("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
    hibernateProperties.setProperty("hibernate.show_sql", "false");
    hibernateProperties.setProperty("hibernate.generate_statistics", "false");
    hibernateProperties.setProperty("hibernate.jdbc.batch_size", "0");
    hibernateProperties.setProperty("hibernate.jdbc.use_streams_for_binary", "true");
    hibernateProperties.setProperty("hibernate.cache.use_second_level_cache", "false");
    hibernateProperties.setProperty("hibernate.hbm2ddl.auto", "create");
    
    bean.setHibernateProperties(hibernateProperties);
    bean.setDataSource(dataSource());
    bean.setAnnotatedClasses(getAnnotatedClasses());
    return bean;
}
 
开发者ID:kibertoad,项目名称:swampmachine,代码行数:18,代码来源:AbstractInMemoryDBHibernateConfiguration.java

示例4: localSessionFactory

import org.springframework.orm.hibernate5.LocalSessionFactoryBean; //导入方法依赖的package包/类
@Bean("sessionFactory")
public LocalSessionFactoryBean localSessionFactory(DataSource dataSource, Properties hibernateProperties) {
    LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
    sessionFactory.setDataSource(dataSource);
    sessionFactory.setPackagesToScan(new String[] { "org.packt.hiber.core.model.data" });
    sessionFactory.setHibernateProperties(hibernateProperties);
    return sessionFactory;
}
 
开发者ID:PacktPublishing,项目名称:Spring-5.0-Cookbook,代码行数:9,代码来源:HiberConfig.java

示例5: sessionFactoryBean

import org.springframework.orm.hibernate5.LocalSessionFactoryBean; //导入方法依赖的package包/类
@Bean
public LocalSessionFactoryBean sessionFactoryBean() {
	LocalSessionFactoryBean localSessionFactoryBean = new LocalSessionFactoryBean();
	localSessionFactoryBean.setDataSource(dataSource());
	localSessionFactoryBean.setPackagesToScan("com.iisigroup.domain");
	Properties properties = new Properties();
	properties.setProperty("hibernate.show_sql", "true");
	localSessionFactoryBean.setHibernateProperties(properties);
	return localSessionFactoryBean;
}
 
开发者ID:lf23617358,项目名称:training-sample,代码行数:11,代码来源:AppConfig.java

示例6: sessionFactory

import org.springframework.orm.hibernate5.LocalSessionFactoryBean; //导入方法依赖的package包/类
@Bean(name = "sessionFactory")
public LocalSessionFactoryBean sessionFactory() throws SQLException{
    LocalSessionFactoryBean localSessionFactoryBean = new LocalSessionFactoryBean();
    localSessionFactoryBean.setDataSource(this.dataSource());
    Properties properties = new Properties();
    properties.setProperty("hibernate.dialect","org.hibernate.dialect.MySQL5Dialect");
    properties.setProperty("hibernate.show_sql","true");
    properties.setProperty("hibernate.format_sql","true");
    localSessionFactoryBean.setHibernateProperties(properties);
    localSessionFactoryBean.setPackagesToScan("me.dragon");
    System.out.println("LocalSessionFactoryBean = " + localSessionFactoryBean);
    return localSessionFactoryBean;
}
 
开发者ID:dragon-yuan,项目名称:Ins_fb_pictureSpider_WEB,代码行数:14,代码来源:DatabaseConfiguration.java

示例7: sessionFactory

import org.springframework.orm.hibernate5.LocalSessionFactoryBean; //导入方法依赖的package包/类
@Bean
public LocalSessionFactoryBean sessionFactory() {
    LocalSessionFactoryBean sessionFactoryBean = new LocalSessionFactoryBean();
    sessionFactoryBean.setDataSource(dataSource());
    sessionFactoryBean.setPackagesToScan(ENTITYMANAGER_PACKAGES_TO_SCAN);
    sessionFactoryBean.setHibernateProperties(hibernateProperties());

    return sessionFactoryBean;
}
 
开发者ID:Exercon,项目名称:AntiSocial-Platform,代码行数:10,代码来源:HibernateConfiguration.java

示例8: createSessionFactoryBean

import org.springframework.orm.hibernate5.LocalSessionFactoryBean; //导入方法依赖的package包/类
protected LocalSessionFactoryBean createSessionFactoryBean() {

		LocalSessionFactoryBean factoryBean = new LocalSessionFactoryBean();
		factoryBean.setDataSource(this.dataSourceConfig.dataSource());

		if (StringUtil.isEmpty(this.propertiesConfig.hibernateDialect())) {
			throw new IllegalStateException("hibernateDialect is required");
		}

		factoryBean.getHibernateProperties().setProperty(AvailableSettings.DIALECT,
				this.propertiesConfig.hibernateDialect());

		if (!ArrayUtil.isEmpty(this.propertiesConfig.hibernateMappingLocations())) {
			factoryBean
					.setMappingLocations(this.propertiesConfig.hibernateMappingLocations());
		}

		// configure for multitenancy
		if (!(this.dataSourceConfig.dataSource() instanceof MultiTenantDataSource)) {
			throw new IllegalStateException("a MultiTenantDataSource is required");
		}

		factoryBean.getHibernateProperties().setProperty(AvailableSettings.MULTI_TENANT,
				MultiTenancyStrategy.DATABASE.toString());
		factoryBean.setMultiTenantConnectionProvider(
				new MultiTenantConnectionProviderImpl((MultiTenantDataSource) this.dataSourceConfig.dataSource()));
		factoryBean.setCurrentTenantIdentifierResolver(
				new CurrentTenantIdentifierResolverImpl(contextConfig.tenantResolver()));

		// update guard
		factoryBean.setEntityInterceptor(new MultiTenantEntityInterceptor(contextConfig.tenantResolver()));

		return factoryBean;

	}
 
开发者ID:RJBTechnology,项目名称:rjb-blog-multitenancy,代码行数:36,代码来源:HibernateConfig.java

示例9: getSessionFactory

import org.springframework.orm.hibernate5.LocalSessionFactoryBean; //导入方法依赖的package包/类
/**
 * Initialize SessionFactory 
 * @return LocalSessionFactoryBean
 */
@Bean
public LocalSessionFactoryBean getSessionFactory() {
	LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
	sessionFactory.setDataSource(getDataSource());
	sessionFactory.setPackagesToScan(new String[] { "com.infotaf.restapi.model" });
	sessionFactory.setHibernateProperties(getHibernateProperties());
	return sessionFactory;
}
 
开发者ID:mjfcolas,项目名称:infotaf,代码行数:13,代码来源:AppConfig.java

示例10: getSessionFactory

import org.springframework.orm.hibernate5.LocalSessionFactoryBean; //导入方法依赖的package包/类
@Bean
public LocalSessionFactoryBean getSessionFactory() {
	LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
	sessionFactory.setDataSource(getDataSource());
	sessionFactory.setPackagesToScan(new String[] { "com.bytestree.model" });
	sessionFactory.setHibernateProperties(getHibernateProperties());
	return sessionFactory;
}
 
开发者ID:bytestree,项目名称:spring4-hibernate5-example,代码行数:9,代码来源:HibernateConfig.java

示例11: sessionFactory

import org.springframework.orm.hibernate5.LocalSessionFactoryBean; //导入方法依赖的package包/类
@Bean
public LocalSessionFactoryBean sessionFactory(final DataSource dataSource) throws IOException, Exception {
    final Properties hp = new Properties();
    
    final LocalSessionFactoryBean factory = new LocalSessionFactoryBean();
    factory.setDataSource(dataSource);
    factory.setPackagesToScan(SpringConf.class.getPackage().getName());
    factory.setHibernateProperties(hp);
    hp.put("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
    hp.put("hibernate.hbm2ddl.auto", "create-drop");
    return factory;
}
 
开发者ID:optionfactory,项目名称:hibernate-json,代码行数:13,代码来源:JsonDriverTest.java

示例12: getSessionFactory

import org.springframework.orm.hibernate5.LocalSessionFactoryBean; //导入方法依赖的package包/类
@Bean
public LocalSessionFactoryBean getSessionFactory() {
	LocalSessionFactoryBean asfb = new LocalSessionFactoryBean();
	asfb.setDataSource(getDataSource());
	asfb.setHibernateProperties(getHibernateProperties());
	asfb.setPackagesToScan(new String[] { "com.sleroux.bank.model" });
	return asfb;
}
 
开发者ID:sylvainleroux,项目名称:bank,代码行数:9,代码来源:BankConfig.java

示例13: sessionFactory

import org.springframework.orm.hibernate5.LocalSessionFactoryBean; //导入方法依赖的package包/类
@Bean
public LocalSessionFactoryBean sessionFactory() {
    LocalSessionFactoryBean localSessionFactoryBean = new LocalSessionFactoryBean();
    localSessionFactoryBean.setDataSource(dataSource());
    localSessionFactoryBean.setPackagesToScan(packagesToScan());
    localSessionFactoryBean.setHibernateProperties(additionalProperties());
    return localSessionFactoryBean;
}
 
开发者ID:vladmihalcea,项目名称:high-performance-java-persistence,代码行数:9,代码来源:HibernateTransactionManagerConfiguration.java

示例14: sessionFactory

import org.springframework.orm.hibernate5.LocalSessionFactoryBean; //导入方法依赖的package包/类
@Bean
LocalSessionFactoryBean sessionFactory() {
    LocalSessionFactoryBean sfb = new LocalSessionFactoryBean();
    sfb.setDataSource(dataSource);
    sfb.setPackagesToScan("com.github.cimsbioko.server.domain");
    Properties props = new Properties();
    props.setProperty("hibernate.dialect", dialect);
    props.setProperty("javax.persistence.validation.mode", "none");
    props.setProperty("hibernate.hbm2ddl.auto", ddlMode);
    sfb.setHibernateProperties(props);
    return sfb;
}
 
开发者ID:cims-bioko,项目名称:cims-server,代码行数:13,代码来源:PersistenceConfig.java


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