em.getTransaction().begin(); StringData sd = em.find(StringData.class, key); System.out.println("Old value: " + sd.getData()); sd.setData(newValue); // em.persist(sd); em.getTransaction().commit();
As you can see, I am not calling persist
, this is commented out because I run this code first. However, as it turned out, this is not so dry. After checking the database, I see that the data has changed (fortunately, this is a test database).
My understanding of Hibernate / JPA seems to be erroneous. Does persist
require data to be modified? And if not, what are the rules when something is saved?
source share