Package org.springframework.orm.hibernate4

Examples of org.springframework.orm.hibernate4.LocalSessionFactoryBean


    public Object postProcessAfterInitialization(Object bean, String beanName)
            throws BeansException {

        if ("sessionFactory".equals(beanName) && bean instanceof LocalSessionFactoryBean) {
            try {
                LocalSessionFactoryBean sessionFactory = (LocalSessionFactoryBean) bean;

                Configuration cfg = new Configuration();
                cfg.configure();

                // load all mappings
View Full Code Here


  public static void main(String[] args)
  {
    FileSystemXmlApplicationContext appContext = new FileSystemXmlApplicationContext(
      "database/spring/applicationContext.xml");

    LocalSessionFactoryBean sessionFactory = (LocalSessionFactoryBean) appContext
      .getBean("&sessionFactory", LocalSessionFactoryBean.class);

    sessionFactory.createDatabaseSchema();
 
View Full Code Here

  public static void main(String[] args)
  {
    FileSystemXmlApplicationContext appContext = new FileSystemXmlApplicationContext(
        "database/spring/applicationContext.xml");
   
    LocalSessionFactoryBean sessionFactory = (LocalSessionFactoryBean) appContext
        .getBean("&sessionFactory", LocalSessionFactoryBean.class);
   
    sessionFactory.updateDatabaseSchema()
 
View Full Code Here

      }
    }
  }

  private SessionFactory getSessionFactory(DataSource dataSource) throws Exception {
    LocalSessionFactoryBean factory = new LocalSessionFactoryBean();
    factory.setDataSource(dataSource);
    factory.setMappingLocations(new Resource[] {
        new ClassPathResource("org/springframework/webflow/persistence/TestBean.hbm.xml"),
        new ClassPathResource("org/springframework/webflow/persistence/TestAddress.hbm.xml") });
    factory.afterPropertiesSet();
    return (SessionFactory) factory.getObject();
  }
View Full Code Here

      }
    }
  }

  private SessionFactory getSessionFactory(DataSource dataSource) throws Exception {
    LocalSessionFactoryBean factory = new LocalSessionFactoryBean();
    factory.setDataSource(dataSource);
    factory.setMappingLocations(new Resource[] {
        new ClassPathResource("org/springframework/webflow/persistence/TestBean.hbm.xml"),
        new ClassPathResource("org/springframework/webflow/persistence/TestAddress.hbm.xml") });
    factory.afterPropertiesSet();
    return (SessionFactory) factory.getObject();
  }
View Full Code Here

        springProcessEngine = new JBPMSpringProcessEngine();
        springProcessEngine.applicationContext = applicationContext;
        springProcessEngine.initializeProcessEngine(configuration);

        // prefixing session factory bean name with "&" to get the factory
        LocalSessionFactoryBean localSessionFactoryBean = sessionFactoryName != null ? (LocalSessionFactoryBean) springProcessEngine
                .get("&" + sessionFactoryName) : springProcessEngine
                .get(LocalSessionFactoryBean.class);
        Configuration hibernateConfiguration = localSessionFactoryBean.getConfiguration();
        springProcessEngine.processEngineWireContext
            .getWireDefinition()
            .addDescriptor(new ProvidedObjectDescriptor(hibernateConfiguration, true));

        springProcessEngine.checkDb(configuration);
View Full Code Here

      springProcessEngine = new SpringProcessEngine();
      springProcessEngine.applicationContext = applicationContext;
      springProcessEngine.initializeProcessEngine(configuration);

      LocalSessionFactoryBean localSessionFactoryBean = springProcessEngine.get(LocalSessionFactoryBean.class);
      Configuration hibernateConfiguration = localSessionFactoryBean.getConfiguration();
      springProcessEngine.processEngineWireContext
          .getWireDefinition()
          .addDescriptor(new ProvidedObjectDescriptor(hibernateConfiguration, true));
     
      springProcessEngine.checkDb(configuration);
View Full Code Here

  }

  public void afterPropertiesSet() throws Exception {

    // setup database
    LocalSessionFactoryBean sessionFactoryBean = findSessionFactoryBean(context);
    sessionFactoryBean.createDatabaseSchema();

    Session session = null;
    Transaction tx = null;
   
    try {
View Full Code Here

    // 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

TOP

Related Classes of org.springframework.orm.hibernate4.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.