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;
}
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;
}
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;
}
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;
}
}
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;
}
Aggregations