Package org.hibernate.cfg

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


        /*assertNotNull(derived.getClassMapping("org.reveng.Child") );
        assertNotNull(derived.getClassMapping("org.reveng.Master") );*/
        URL[] urls = new URL[] { outputdir.toURL() };
        URLClassLoader ucl = new URLClassLoader(urls, Thread.currentThread().getContextClassLoader() );
        Thread.currentThread().setContextClassLoader(ucl);
        SessionFactory factory = derived.buildSessionFactory();
        Session session = factory.openSession();
       
        executeDDL(getGenDataSQL(), false);
        session.createQuery("from Lineitem").list();
        List list = session.createQuery("from Product").list();
View Full Code Here


      is.close();
      System.err.println("Loaded serializable configuration:" + (System.currentTimeMillis() - start) / 1000.0 + " sec.");
    }
    start = System.currentTimeMillis();
    System.err.println("Start build of session factory");
    SessionFactory factory = cfg.buildSessionFactory();
    System.err.println("Build session factory:" + (System.currentTimeMillis() - start) / 1000.0 + " sec.");
    return factory;
  }

View Full Code Here

      ac.addAnnotatedClass(Class.forName("org.opentides.bean.user.UserRole"));
      ac.addAnnotatedClass(Class.forName("org.opentides.bean.user.UserCredential"));
      ac.addAnnotatedClass(Class.forName("org.opentides.bean.user.UserGroup"));
      ac.addAnnotatedClass(Class.forName("org.opentides.bean.UserDefinedRecord"));
      ac.addAnnotatedClass(Class.forName("org.opentides.bean.UserDefinedField"));
            sessionFactory = ac.buildSessionFactory();
        } catch (Throwable ex) {
            // Make sure you log the exception, as it might be swallowed
            System.err.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
        }
View Full Code Here

                // Create the SessionFactory from hibernate.cfg.xml
              Configuration config = new Configuration().configure();
              config.setProperty("hibernate.connection.username", username);
              config.setProperty("hibernate.connection.password", password);
             
              sessionFactory = config.buildSessionFactory();
            } catch (Throwable ex) {
                // Make sure you log the exception, as it might be swallowed
                System.err.println("Initial SessionFactory creation failed." + ex);
                throw new ExceptionInInitializerError(ex);
            }
View Full Code Here

      // Create database schema in each run
      cfg.setProperty(Environment.HBM2DDL_AUTO, "create-drop");

      StandardServiceRegistryImpl registry =
            ServiceRegistryBuilder.buildServiceRegistry(cfg.getProperties());
      sessionFactory =  cfg.buildSessionFactory(registry);

      tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
   }

   private static void configureMappings(Configuration cfg) {
View Full Code Here

      // Create database schema in each run
      cfg.setProperty(Environment.HBM2DDL_AUTO, "create-drop");

      StandardServiceRegistryImpl registry =
            ServiceRegistryBuilder.buildServiceRegistry(cfg.getProperties());
      sessionFactory =  cfg.buildSessionFactory(registry);

      tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
   }

   protected String getProvider() {
View Full Code Here

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

        for (HibernateConfigurer configurer : hibernateConfigurers)
            configurer.configure(configuration);

        long configurationComplete = System.currentTimeMillis();

        _sessionFactory = configuration.buildSessionFactory();
        _configuration = new ImmutableConfiguration(configuration);

        long factoryCreated = System.currentTimeMillis();

        logger.info(HibernateMessages.startupTiming(
View Full Code Here

            Configuration cfg = new Configuration()
            .addAnnotatedClass(DictionaryCategory.class)
            .addAnnotatedClass(Dictionary.class)
            .configure();
          new SchemaExport(cfg).create(false, true);
            return cfg.buildSessionFactory();
        }
        catch (Exception ex) {
            // Make sure you log the exception, as it might be swallowed
            System.err.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
View Full Code Here

        final ServiceRegistry registry = new StandardServiceRegistryBuilder()
                .addService(ConnectionProvider.class, connectionProvider)
                .applySettings(properties)
                .build();

        return configuration.buildSessionFactory(registry);
    }

    private void addAnnotatedClasses(Configuration configuration,
                                     Iterable<Class<?>> entities) {
        final SortedSet<String> entityClasses = Sets.newTreeSet();
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.