Search in sources :

Example 1 with LocalSessionFactoryBean

use of org.springframework.orm.hibernate5.LocalSessionFactoryBean in project yqq by yeycfri.

the class HibernateConfig method sessionFactory.

@Bean
public LocalSessionFactoryBean sessionFactory() {
    LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
    sessionFactory.setDataSource(dataSource());
    sessionFactory.setPackagesToScan(new String[] { "org.yqq.model" });
    sessionFactory.setHibernateProperties(hibernateProperties());
    return sessionFactory;
}
Also used : LocalSessionFactoryBean(org.springframework.orm.hibernate4.LocalSessionFactoryBean) Bean(org.springframework.context.annotation.Bean) LocalSessionFactoryBean(org.springframework.orm.hibernate4.LocalSessionFactoryBean)

Example 2 with LocalSessionFactoryBean

use of org.springframework.orm.hibernate5.LocalSessionFactoryBean in project tutorials by eugenp.

the class HibernateConf method sessionFactory.

@Bean
public LocalSessionFactoryBean sessionFactory() {
    final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
    sessionFactory.setDataSource(dataSource());
    sessionFactory.setPackagesToScan(new String[] { "com.baeldung.hibernate.bootstrap.model" });
    sessionFactory.setHibernateProperties(hibernateProperties());
    return sessionFactory;
}
Also used : LocalSessionFactoryBean(org.springframework.orm.hibernate5.LocalSessionFactoryBean) LocalSessionFactoryBean(org.springframework.orm.hibernate5.LocalSessionFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 3 with LocalSessionFactoryBean

use of org.springframework.orm.hibernate5.LocalSessionFactoryBean in project tutorials by eugenp.

the class PersistenceConfig method sessionFactory.

@Bean
public LocalSessionFactoryBean sessionFactory() {
    final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
    sessionFactory.setDataSource(restDataSource());
    sessionFactory.setPackagesToScan(new String[] { "com.baeldung.hibernate.manytomany" });
    sessionFactory.setHibernateProperties(hibernateProperties());
    return sessionFactory;
}
Also used : LocalSessionFactoryBean(org.springframework.orm.hibernate5.LocalSessionFactoryBean) LocalSessionFactoryBean(org.springframework.orm.hibernate5.LocalSessionFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 4 with LocalSessionFactoryBean

use of org.springframework.orm.hibernate5.LocalSessionFactoryBean in project tephra by heisedebaise.

the class SessionFactoryImpl method createSessionFactory.

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;
    }
}
Also used : LocalSessionFactoryBean(org.springframework.orm.hibernate5.LocalSessionFactoryBean) IOException(java.io.IOException)

Example 5 with LocalSessionFactoryBean

use of org.springframework.orm.hibernate5.LocalSessionFactoryBean in project tutorials by eugenp.

the class PersistenceConfigHibernate3 method sessionFactory.

@Bean
public LocalSessionFactoryBean sessionFactory() {
    final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
    Resource config = new ClassPathResource("exceptionDemo.cfg.xml");
    sessionFactory.setDataSource(dataSource());
    sessionFactory.setConfigLocation(config);
    sessionFactory.setHibernateProperties(hibernateProperties());
    return sessionFactory;
}
Also used : ClassPathResource(org.springframework.core.io.ClassPathResource) Resource(org.springframework.core.io.Resource) LocalSessionFactoryBean(org.springframework.orm.hibernate3.LocalSessionFactoryBean) ClassPathResource(org.springframework.core.io.ClassPathResource) LocalSessionFactoryBean(org.springframework.orm.hibernate3.LocalSessionFactoryBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

Bean (org.springframework.context.annotation.Bean)17 LocalSessionFactoryBean (org.springframework.orm.hibernate4.LocalSessionFactoryBean)12 LocalSessionFactoryBean (org.springframework.orm.hibernate5.LocalSessionFactoryBean)7 Properties (java.util.Properties)6 IOException (java.io.IOException)2 Resource (org.springframework.core.io.Resource)2 LocalSessionFactoryBean (org.springframework.orm.hibernate3.LocalSessionFactoryBean)2 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)1 SqlRepositoryBeanConfig (com.evolveum.midpoint.repo.sql.SqlRepositoryBeanConfig)1 DataSourcePropertiesBean (com.remswork.project.alice.bean.DataSourcePropertiesBean)1 SqlSessionFactoryBean (org.mybatis.spring.SqlSessionFactoryBean)1 FactoryBean (org.springframework.beans.factory.FactoryBean)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 DependsOn (org.springframework.context.annotation.DependsOn)1 ClassPathResource (org.springframework.core.io.ClassPathResource)1 LocalContainerEntityManagerFactoryBean (org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)1 SchedulerFactoryBean (org.springframework.scheduling.quartz.SchedulerFactoryBean)1