【发布时间】:2011-12-04 06:39:21
【问题描述】:
我正在尝试使用 JPA 和 Google App Engine 更新实体。我开始一个事务,检索要更新的实体,更改一些字段,调用持久化并提交。一切都执行没有任何错误,但是实体没有被修改。
这里是示例代码:
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();
}
}
我应该怎么做才能使用 JPA 持久化实体?
【问题讨论】:
标签: java google-app-engine jpa