本文整理汇总了Java中org.springframework.orm.hibernate5.LocalSessionFactoryBean.setPackagesToScan方法的典型用法代码示例。如果您正苦于以下问题:Java LocalSessionFactoryBean.setPackagesToScan方法的具体用法?Java LocalSessionFactoryBean.setPackagesToScan怎么用?Java LocalSessionFactoryBean.setPackagesToScan使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.orm.hibernate5.LocalSessionFactoryBean
的用法示例。
在下文中一共展示了LocalSessionFactoryBean.setPackagesToScan方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
}
示例2: 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;
}
示例3: 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;
}
示例4: 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;
}
示例5: 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;
}
示例6: 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;
}
示例7: 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;
}
示例8: 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;
}
示例9: 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;
}
示例10: 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
示例11: 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;
}