Esempio n. 1
0
  static {
    try {
      Map<Object, Object> properties = getEntityManagerProperties();

      Environment.verifyProperties(properties);
      ConfigurationHelper.resolvePlaceHolders(properties);
      ServiceRegistry reg =
          new ServiceRegistryBuilder().applySettings(properties).buildServiceRegistry();

      DbOpenHelper openHelper =
          new DbOpenHelper(reg) {

            @Override
            public void onCreate() throws Exception {
              executeAllScript(0);
            }

            @Override
            public void onUpgrade(int oldVersion, int newVersion) throws Exception {
              // TODO Auto-generated method stub
            }
          };
      openHelper.open();

      emfInstance =
          Persistence.createEntityManagerFactory(
              "transactions-optional", getEntityManagerProperties());

    } catch (Throwable t) {
      log.error("Error creating EMF", t);
    }
  }