private void closeEntityManager(){
  EntityManager entityManager=getEntityManager();
  if (entityManager != null && entityManager.isOpen()) {
    entityManager.close();
    entityManagerThreadLocal.set(null);
  }
}

private void closeEntityManager ( ) { EntityManager entityManager = getEntityManager ( ) ; if ( entityManager != null && entityManager . isOpen ( ) ) { entityManager . close ( ) ; entityManagerThreadLocal . set ( null ) ; } }
closes an entity manager if it is open .
