public static void closeEntityManager() {
        EntityManager m = JPAUtil.manager.get();
        if (m != null) {
            EntityTransaction t = m.getTransaction();
            if (t.isActive()) { // TODO
                // CoreLog.getInstance()
                // .getLog()
                // .warn("EntityManager contains an active transaction, commiting transaction");
                // t.commit();
            }
            m.flush();
            m.close();
            JPAUtil.manager.set(null);
        }
    }