Reputation: 85496
I'm trying to update an entity using JPA with Google App Engine. I start a transaction, retrieve the entity to update, change a few fields, call persist and commit. Everything is executed without any error, however, the entity is not modified.
Here is the sample code:
EntityTransaction tx = entityManager.getTransaction();
try {
tx.begin();
DomainName domain = entityManager.find(DomainName.class, domainName);
domain.setExists(body != null);
domain.setHttpBody(body);
domain.setHttpTimeStamp(new Date());
entityManager.persist(domain);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
}
What should I do to persist the entity using JPA?
Upvotes: 2
Views: 960
Reputation: 15577
No idea what the persist() call is doing, since the object (if found, which you don't tell us) will be in managed state, hence the first update of a field marks the object as dirty, and will be committed on the commit() call. Obviously a simple inspection of the log would tell you what was happening.
Upvotes: 2