當前位置: 首頁>>代碼示例>>Java>>正文


Java LocalSessionFactoryBean.afterPropertiesSet方法代碼示例

本文整理匯總了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));
}
 
開發者ID:zhaojunfei,項目名稱:lemon,代碼行數:25,代碼來源:RecoverableSessionFactoryBean.java

示例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;
    }
}
 
開發者ID:amalio,項目名稱:spring-json-sms-gateway,代碼行數:18,代碼來源:DataConfig.java

示例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;
    }
}
 
開發者ID:amalio,項目名稱:spring-json-sms-gateway,代碼行數:18,代碼來源:DataConfig.java

示例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();
}
 
開發者ID:debop,項目名稱:hibernate-examples,代碼行數:38,代碼來源:AbstractHibernateConfiguration.java

示例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);
    }
}
 
開發者ID:debop,項目名稱:debop4j,代碼行數:37,代碼來源:HibernateConfigBase.java


注:本文中的org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。