Package org.springframework.orm.hibernate3

Examples of org.springframework.orm.hibernate3.LocalSessionFactoryBean


    // setRootRequestMapper(new CryptoMapper(getRootRequestMapper(), this));
    final XmlWebApplicationContext webApplicationContext = (XmlWebApplicationContext) WebApplicationContextUtils
        .getWebApplicationContext(getServletContext());
    final ConfigurableListableBeanFactory beanFactory = webApplicationContext.getBeanFactory();
    beanFactory.autowireBeanProperties(this, AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, false);
    final LocalSessionFactoryBean localSessionFactoryBean = (LocalSessionFactoryBean) beanFactory.getBean("&sessionFactory");
    final org.hibernate.cfg.Configuration hibernateConfiguration = localSessionFactoryBean.getConfiguration();
    final PluginsRegistry pluginsRegistry = PluginsRegistry.instance();
    pluginsRegistry.set(getResourceSettings());
    projectForgeApp = ProjectForgeApp.init(beanFactory, hibernateConfiguration);
    // Own error page for deployment mode and UserException and AccessException.
    getRequestCycleListeners().add(new AbstractRequestCycleListener() {
View Full Code Here


        try {
          jdbc.execute("CHECKPOINT DEFRAG");
        } catch (final org.springframework.jdbc.BadSqlGrammarException ex) {
          // ignore
        }
        final LocalSessionFactoryBean localSessionFactoryBean = (LocalSessionFactoryBean) ctx.getBean("&sessionFactory");
        HibernateUtils.setConfiguration(localSessionFactoryBean.getConfiguration());
      } catch (final Throwable ex) {
        log.error(ex.getMessage(), ex);
        throw new RuntimeException(ex);
      }
    } else {
View Full Code Here

  protected SessionFactory createSessionFactory(DbDialect dialect) {
    SessionFactory result = getHibernateSessionFactory();
    if (result != null) {
      return result;
    }
    LocalSessionFactoryBean factory = getHibernateFactoryBean();
    if (factory == null) {
      String[] files = createHibernateFiles();
      if (files.length == 0) {
        return null; // Hibernate not required
      }
      factory = new LocalSessionFactoryBean();
      factory.setMappingResources(files);
      factory.setDataSource(getDataSource());
      Properties props = new Properties();
      props.setProperty("hibernate.dialect", dialect.getHibernateDialect().getClass().getName());
      props.setProperty("hibernate.show_sql", String.valueOf(isHibernateShowSql()));
      props.setProperty("hibernate.connection.release_mode", "on_close");
      if (isAllowHibernateThreadBoundSession()) {
        props.setProperty(Environment.CURRENT_SESSION_CONTEXT_CLASS, "thread");
        props.setProperty(Environment.TRANSACTION_STRATEGY, "org.hibernate.transaction.JDBCTransactionFactory");
      }
      factory.setHibernateProperties(props);
      factory.setLobHandler(dialect.getLobHandler());
    }
    try {
      factory.afterPropertiesSet();
    } catch (Exception ex) {
      throw new RuntimeException(ex);
    }
    return factory.getObject();
  }
View Full Code Here

   */
  protected SessionFactory createHibernateSessionFactory(DbDialect dialect) {
    if (getHibernateMappingFiles() == null) {
      return null; // Hibernate not required
    }
    LocalSessionFactoryBean factory = new LocalSessionFactoryBean();
    factory.setMappingResources(getHibernateMappingResources());
    factory.setDataSource(getDataSource());
    Properties props = new Properties();
    props.setProperty("hibernate.dialect", dialect.getHibernateDialect().getClass().getName());
    props.setProperty("hibernate.show_sql", String.valueOf(isHibernateShowSql()));
    props.setProperty("hibernate.connection.release_mode", "on_close");
    if (isAllowHibernateThreadBoundSession()) {
      props.setProperty(Environment.CURRENT_SESSION_CONTEXT_CLASS, "thread");
      props.setProperty(Environment.TRANSACTION_STRATEGY, "org.hibernate.transaction.JDBCTransactionFactory");
    }
    factory.setHibernateProperties(props);
    factory.setLobHandler(dialect.getLobHandler());
    try {
      factory.afterPropertiesSet();
    } catch (Exception ex) {
      throw new RuntimeException(ex);
    }
    return factory.getObject();
  }
View Full Code Here

        this.ctx = applicationContext;
    }


    public void afterPropertiesSet() throws Exception {
        LocalSessionFactoryBean hsf = (LocalSessionFactoryBean) BeanFactoryUtils
                .beanOfTypeIncludingAncestors(ctx, LocalSessionFactoryBean.class);
        Bootstrapper bootstrapper = new Bootstrapper(dataSource, transactionManager, hsf
                .getConfiguration(), sessionFactory, userService, workspaceManagerLogin,
                workspaceManagerPassword);
        bootstrapper.bootstrap();
    }
View Full Code Here

    transactionManager.rollback(transactionStatus);
  }

  private SessionFactory createTestSessionFactory() throws Exception {
    // create a FactoryBean to help create a Hibernate SessionFactory
    LocalSessionFactoryBean factoryBean = new LocalSessionFactoryBean();
    factoryBean.setDataSource(createTestDataSource());
    Resource[] mappingLocations = new ClassPathResource[] {
        new ClassPathResource("Account.hbm.xml", HibernateAccountManager.class),
        new ClassPathResource("Beneficiary.hbm.xml", HibernateAccountManager.class) };
    factoryBean.setMappingLocations(mappingLocations);
    factoryBean.setHibernateProperties(createHibernateProperties());
    // initialize according to the Spring InitializingBean contract
    factoryBean.afterPropertiesSet();
    // get the created session factory
    return (SessionFactory) factoryBean.getObject();
  }
View Full Code Here

    assertEquals("wrong allocation percentage", Percentage.valueOf("50%"), b2.getAllocationPercentage());
  }

  private SessionFactory createTestSessionFactory() throws Exception {
    // simulate the Spring bean initialization lifecycle
    LocalSessionFactoryBean factoryBean = new LocalSessionFactoryBean();
    factoryBean.setDataSource(createTestDataSource());
    Resource[] mappingLocations = new ClassPathResource[] {
        new ClassPathResource("Account.hbm.xml", Account.class),
        new ClassPathResource("Beneficiary.hbm.xml", Beneficiary.class) };
    factoryBean.setMappingLocations(mappingLocations);
    factoryBean.afterPropertiesSet();
    return (SessionFactory) factoryBean.getObject();
  }
View Full Code Here

        .getBenefitAvailabilityPolicy());
  }

  private SessionFactory createTestSessionFactory() throws Exception {
    // simulate the Spring bean initialization lifecycle
    LocalSessionFactoryBean factoryBean = new LocalSessionFactoryBean();
    factoryBean.setDataSource(createTestDataSource());
    Resource[] mappingLocations = new ClassPathResource[] { new ClassPathResource("Restaurant.hbm.xml",
        Restaurant.class) };
    factoryBean.setMappingLocations(mappingLocations);
    factoryBean.afterPropertiesSet();
    return (SessionFactory) factoryBean.getObject();
  }
View Full Code Here

    transactionManager.rollback(transactionStatus);
  }

  private SessionFactory createTestSessionFactory() throws Exception {
    // create a FactoryBean to help create a Hibernate SessionFactory
    LocalSessionFactoryBean factoryBean = new LocalSessionFactoryBean();
    factoryBean.setDataSource(createTestDataSource());
    Resource[] mappingLocations = new ClassPathResource[] { new ClassPathResource("Restaurant.hbm.xml",
        Restaurant.class) };
    factoryBean.setMappingLocations(mappingLocations);
    factoryBean.setHibernateProperties(createHibernateProperties());
    // initialize according to the Spring InitializingBean contract
    factoryBean.afterPropertiesSet();
    // get the created session factory
    return (SessionFactory) factoryBean.getObject();
  }
View Full Code Here

    transactionManager.rollback(transactionStatus);
  }

  private SessionFactory createTestSessionFactory() throws Exception {
    // create a FactoryBean to help create a Hibernate SessionFactory
    LocalSessionFactoryBean factoryBean = new LocalSessionFactoryBean();
    factoryBean.setDataSource(createTestDataSource());
    Resource[] mappingLocations = new ClassPathResource[] {
        new ClassPathResource("Account.hbm.xml", Account.class),
        new ClassPathResource("Beneficiary.hbm.xml", Beneficiary.class) };
    factoryBean.setMappingLocations(mappingLocations);
    factoryBean.setHibernateProperties(createHibernateProperties());
    // initialize according to the Spring InitializingBean contract
    factoryBean.afterPropertiesSet();
    // get the created session factory
    return (SessionFactory) factoryBean.getObject();
  }
View Full Code Here

TOP

Related Classes of org.springframework.orm.hibernate3.LocalSessionFactoryBean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.