private synchronized void buildEntityManagerFactory(){
  if (entityManagerFactory != null) {
    return;
  }
  registerShutdownHook(this);
  Map<String,Object> configOverrides=new HashMap<String,Object>();
  String dbPath=dbDirectory.getAbsolutePath();
  configOverrides.put("hibernate.search.default.indexBase",dbPath);
  configOverrides.put("hibernate.connection.url","jdbc:h2:" + dbPath + File.separator+ "db"+ ";LOCK_MODE=1"+ ";DB_CLOSE_DELAY=-1");
  entityManagerFactory=Persistence.createEntityManagerFactory("manager",configOverrides);
}

private synchronized void buildEntityManagerFactory ( ) { if ( entityManagerFactory != null ) { return ; } registerShutdownHook ( this ) ; Map < String , Object > configOverrides = new HashMap < String , Object > ( ) ; String dbPath = dbDirectory . getAbsolutePath ( ) ; configOverrides . put ( "hibernate.search.default.indexBase" , dbPath ) ; configOverrides . put ( "hibernate.connection.url" , "jdbc:h2:" + dbPath + File . separator + "db" + ";LOCK_MODE=1" + ";DB_CLOSE_DELAY=-1" ) ; entityManagerFactory = Persistence . createEntityManagerFactory ( "manager" , configOverrides ) ; }
create a jpa entity manager factory which is used to create entity managers which are used to query and commit to the db .
