I am trying to save to database changes made to a detached entity. The object of the entity is passed to the function by argument (named as data):
private boolean generate(CommonGameData data) {
        boolean result = true;
        EntityManager em = HibernateUtil.currentEntityManager();
        try {
            em.getTransaction().begin();
            em.merge(data);
            em.flush();
            ...some changes to data object...
            em.persist(data);
            em.flush();
            em.getTransaction().commit();
    } catch (Exception ex) {
        ...
        return false;
    }
        return true;
}
As I have read if I am using the detached entity, I should call merge first. But after commit is done successfully, I don't see any changes in database. Where is the mistake?
 
    