title: Hibernate using Programmatic Configuration, starting hibernate.hbm2ddl.auto
body: <p>I am configuration my hibernate sessionfactory programmatically:</p>
  
  <p><a href="http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/session-configuration.html#configuration-programmatic" rel="nofollow">http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/session-configuration.html#configuration-programmatic</a></p>
  
  <pre><code>private static SessionFactory buildSessionFactory() {
  
          // Create the SessionFactory from hibernate.cfg.xml
          Configuration configuration = new Configuration();
          configuration.configure();
  
          configuration.setProperty("hibernate.connection.url", myUrl);
          configuration.setProperty("hibernate.connection.username", myUser);
          configuration.setProperty("hibernate.connection.password", myPass);
  
          serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry(); 
  
          return configuration.buildSessionFactory(serviceRegistry);
  }
  </code></pre>
  
  <p><strong>But problem, is that these properties are loaded only, when using hibernate operation from dao.</strong></p>
  
  <pre><code>protected void startOperation() {
      session = HibernateUtil.getSessionFactory().openSession();
      tx = session.beginTransaction();
  }
  </code></pre>
  
  <p>Therefore, when my application boots up, then hibernate.hbm2ddl.auto doesn't seem to work. Can I somehow force hibernate.hbm2ddl.auto to start in my program or any other solution?</p>
  
  <p><strong>Suggetions or other options, thoughts?</strong></p>