本文整理匯總了Java中org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet方法的典型用法代碼示例。如果您正苦於以下問題:Java LocalSessionFactoryBean.afterPropertiesSet方法的具體用法?Java LocalSessionFactoryBean.afterPropertiesSet怎麽用?Java LocalSessionFactoryBean.afterPropertiesSet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.orm.hibernate4.LocalSessionFactoryBean
的用法示例。
在下文中一共展示了LocalSessionFactoryBean.afterPropertiesSet方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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));
}
示例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;
}
}
示例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;
}
}
示例4: sessionFactory
import org.springframework.orm.hibernate4.LocalSessionFactoryBean; //導入方法依賴的package包/類
/**
* Hibernate {@link SessionFactory} 를 빌드합니다.
*
* @return {@link SessionFactory} instance.
*/
@Bean
public SessionFactory sessionFactory() throws IOException {
log.info("SessionFactory Bean을 생성합니다...");
LocalSessionFactoryBean factoryBean = new LocalSessionFactoryBean();
String[] packagenames = getMappedPackageNames();
if (packagenames != null && packagenames.length > 0) {
log.debug("hibernate용 entity를 scan합니다. packages=[{}]", packagenames);
factoryBean.setPackagesToScan(packagenames);
}
// Naming strategy
NamingStrategy ns = getNamingStrategy();
if (ns != null)
factoryBean.setNamingStrategy(ns);
// Hibernate properties
factoryBean.setHibernateProperties(hibernateProperties());
factoryBean.setDataSource(dataSource());
Interceptor interceptor = hibernateInterceptor();
if (interceptor != null)
factoryBean.setEntityInterceptor(hibernateInterceptor());
setupSessionFactory(factoryBean);
factoryBean.afterPropertiesSet();
log.info("SessionFactory Bean을 생성했습니다!!!");
return factoryBean.getObject();
}
示例5: sessionFactory
import org.springframework.orm.hibernate4.LocalSessionFactoryBean; //導入方法依賴的package包/類
/**
* Provide Hibernate ISessionFactory.
*
* @return the session factory
*/
@Bean
public SessionFactory sessionFactory() {
if (log.isInfoEnabled())
log.info("SessionFactory Bean을 생성합니다...");
LocalSessionFactoryBean factoryBean = new LocalSessionFactoryBean();
String[] packageNames = getMappedPackageNames();
if (packageNames != null) {
log.info("hibernate용 entity를 scan합니다. packages=[{}]", StringTool.listToString(packageNames));
factoryBean.setPackagesToScan(packageNames);
}
factoryBean.setHibernateProperties(hibernateProperties());
factoryBean.setDataSource(dataSource());
factoryBean.setEntityInterceptor(hibernateInterceptor());
// Drived class에서 추가 작업을 수행할 수 있도록 합니다.
setupSessionFactory(factoryBean);
try {
factoryBean.afterPropertiesSet();
log.info("SessionFactory Bean을 생성했습니다!!!");
return factoryBean.getObject();
} catch (IOException e) {
throw new RuntimeException("SessionFactory 빌드에 실패했습니다.", e);
}
}