Package org.hibernate.cfg

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


    try {
      Configuration cfg = new Configuration().configure("hibernate.cfg.xml");  
      StandardServiceRegistryBuilder sb = new StandardServiceRegistryBuilder();
      sb.applySettings(cfg.getProperties());
      StandardServiceRegistry standardServiceRegistry = sb.build();            
       sessionFactory = cfg.buildSessionFactory(standardServiceRegistry);
    } catch (Throwable ex) {
      System.err.println("Failed to create sessionFactory object." + ex);
      throw new ExceptionInInitializerError(ex);
    }
    System.out.println("Hibernate One to Many Mapping Example Using XML ");
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

     * @param servletContext the servlet context
     */
    public void onInit(ServletContext servletContext) {
        Configuration configuration = createConfiguration();
        initConfiguration(configuration);
        sessionFactory = configuration.buildSessionFactory();
    }

    /**
     * Creates and returns a new Configuration instance.
     * <p/>
 
View Full Code Here

     * @param servletContext the servlet context
     */
    public void onInit(ServletContext servletContext) {
        Configuration configuration = createConfiguration();
        initConfiguration(configuration);
        sessionFactory = configuration.buildSessionFactory();
    }

    /**
     * Creates and returns a new Configuration instance.
     * <p/>
 
View Full Code Here

      // cfg.addResource("Item.hbm.xml");
      cfg.addClass(Item.class).setProperty("hibernate.dialect",
          "org.hibernate.dialect.MySQLInnoDBDialect");
      cfg.setProperty("hibernate.hbm2ddl.auto", "update");
      cfg.setProperty("show_sql", "true");
      SessionFactory factory = cfg.buildSessionFactory();
      session = factory.openSession(conn);
    } catch (ClassNotFoundException e) {
      e.printStackTrace(System.err);
    } catch (SQLException e) {
      e.printStackTrace(System.err);
View Full Code Here

    public void testCreateSessionFactory() {
        Configuration configuration = new Configuration();
        configuration.setProperties(EvolizerSessionHandler.getDefaultHsqldbInMemoryConfig("test"));

        configuration.addAnnotatedClass(Entity.class);
        SessionFactory factory = configuration.buildSessionFactory();
        Session hibernateSession = factory.openSession();

        assertNotNull("Session must not be null", hibernateSession);
        hibernateSession.close();
    }
View Full Code Here

                if (dbUrl.startsWith("jdbc:")) {
                    dbUrl = dbUrl.substring("jdbc:".length());
                }
                if (!fSessionFactoryMap.containsKey(dbUrl)) {
                    Configuration configuration = configureDataBaseConnection(properties);
                    fSessionFactoryMap.put(dbUrl, configuration.buildSessionFactory());
                    fConnectionPropertiesMap.put(dbUrl, properties);
                }
            } else {
                throw new EvolizerException("Properties must contain the 'hibernate.connection.url' entry");
            }
View Full Code Here

      configuration.registerTypeContributor( typeContributor );
    }

    final ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder( builder.build() )
        .applySettings( configuration.getProperties() ).build();
    return configuration.buildSessionFactory( serviceRegistry );
  }

  @Override
  public void ungetService(Bundle requestingBundle, ServiceRegistration registration, Object service) {
    ((SessionFactory) service).close();
View Full Code Here

      configuration.registerTypeContributor( typeContributor );
    }

    final ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder( builder.build() )
        .applySettings( configuration.getProperties() ).build();
    return configuration.buildSessionFactory( serviceRegistry );
  }

  @Override
  public void ungetService(Bundle requestingBundle, ServiceRegistration registration, Object service) {
    ((SessionFactory) service).close();
View Full Code Here

    configuration.setProperty( Environment.DIALECT, getDialect().getClass().getName() );

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

    SessionFactory sessionFactory = configuration.buildSessionFactory();
    this.configuration = configuration;
    this.sessionFactory = sessionFactory;

    settings.afterSessionFactoryBuilt( ( SessionFactoryImplementor ) 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.