public static EntityManager getEntityManager() {
        if (JPAUtil.factory == null) {
            JPAUtil.factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
        }
        EntityManager m = JPAUtil.manager.get();
        if (m == null) {
            m = JPAUtil.factory.createEntityManager();
            JPAUtil.manager.set(m);
        }
        return m;
    }