Package org.hibernate.cfg

Examples of org.hibernate.cfg.Configuration.buildSessionFactory()


                return name.endsWith( ".hbm.xml" );
              }
            }
        )
    );
    SessionFactory factory = configuration.buildSessionFactory();
    long initial = System.currentTimeMillis() - start;
    factory.close();

    start = System.currentTimeMillis();
    configuration = buildConfigurationFromCacheableFiles(
View Full Code Here


                return name.endsWith( ".hbm.xml" );
              }
            }
        )
    );
    factory = configuration.buildSessionFactory();
    long subsequent = System.currentTimeMillis() - start;

    // Let's make sure the mappings were read in correctly (in termas of they are operational).
    Session session = factory.openSession();
    session.beginTransaction();
View Full Code Here

      iter = cfg.getCollectionMappings();
      while (iter.hasNext()) {
         Collection coll = (Collection) iter.next();
         cfg.setCollectionCacheConcurrencyStrategy(coll.getRole(), "transactional");
      }
      return cfg.buildSessionFactory();
   }
}
View Full Code Here

     * @throws HibernateException
     */
    private static SessionFactory configureSessionFactory() throws HibernateException {
        Configuration configuration = new Configuration();
        configuration.configure();
        sessionFactory = configuration.buildSessionFactory();
        return sessionFactory;
    }
}

View Full Code Here

    settings.afterConfigurationBuilt( configuration.createMappings(), getDialect() );

    this.configuration = configuration;

    serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( getServiceRegistryProperties() );
    sessionFactory = configuration.buildSessionFactory( serviceRegistry );

    settings.afterSessionFactoryBuilt( ( SessionFactoryImplementor ) sessionFactory );
  }

  private Map getServiceRegistryProperties() {
View Full Code Here

      String batchSize = config.getProperty("hibernate.jdbc.batch_size");
      Integer batchSizeNumber = Integer.valueOf(batchSize);
      this.setBatchSize(batchSizeNumber.intValue());
     
      ServiceRegistry registry = new ServiceRegistryBuilder().applySettings(config.getProperties()).buildServiceRegistry();
      SessionFactory factory = config.buildSessionFactory(registry);
      setSessionFactory(factory);
    } catch (HibernateException exception) {
      StringBuffer msg = new StringBuffer();
      msg.append("Error when loading Hibernate configuration file. Message: '").append(exception.getMessage()).append("'.");
      throw new SessionFactoryConfigurationException(msg.toString(), exception);
View Full Code Here

      String batchSize = config.getProperty("hibernate.jdbc.batch_size");
      Integer batchSizeNumber = Integer.valueOf(batchSize);
      this.setBatchSize(batchSizeNumber.intValue());
     
      ServiceRegistry registry = new ServiceRegistryBuilder().applySettings(config.getProperties()).buildServiceRegistry();
      SessionFactory factory = config.buildSessionFactory(registry);
      setSessionFactory(factory);
    } catch (HibernateException exception) {
      StringBuffer msg = new StringBuffer();
      msg.append("Error when loading Hibernate configuration file. Message: '").append(exception.getMessage()).append("'.");
      throw new SessionFactoryConfigurationException(msg.toString(), exception);
View Full Code Here

      }
      Integer batchSizeNumber = Integer.valueOf(batchSize);
      this.setBatchSize(batchSizeNumber.intValue());
     
      ServiceRegistry registry = new ServiceRegistryBuilder().applySettings(config.getProperties()).buildServiceRegistry();
      SessionFactory factory = config.buildSessionFactory(registry);
      setSessionFactory(factory);
    } catch (HibernateException exception) {
      StringBuffer msg = new StringBuffer();
      msg.append("Error when loading Hibernate configuration file. Message: '").append(exception.getMessage()).append("'.");
      throw new SessionFactoryConfigurationException(msg.toString(), exception);
View Full Code Here

        Configuration cfg = new Configuration();
        cfg.setProperties(prop);
        cfg.addFile(mappingFile);

        factory = cfg.buildSessionFactory();
    }

    public void destroy() {
        try {
            closeSession();
View Full Code Here

    annotationConfiguration.configure("hibernate.cfg.xml");
  //  new SchemaExport(annotationConfiguration).create(true,true);
   
    Configuration configuration = new Configuration();
    configuration.configure();
    sessionFactory = configuration.buildSessionFactory();
    return sessionFactory;
  }
}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.