Google app engine 无法更新现有JDO对象并保留新更新的数据
我一直在尝试从多个线程的解决方案,但还没有运气 任何人都可以通过代码快速地了解到正在发生的事情?我在下面分享了我的更新代码。感谢您的快速帮助Google app engine 无法更新现有JDO对象并保留新更新的数据,google-app-engine,jdo,datapersistance,Google App Engine,Jdo,Datapersistance,我一直在尝试从多个线程的解决方案,但还没有运气 任何人都可以通过代码快速地了解到正在发生的事情?我在下面分享了我的更新代码。感谢您的快速帮助 @ApiMethod(name="updateContact", path = "updateContact", httpMethod = "GET") public OpinionModel updateEmployeeTitle(@Named("id") Long id,@Named("selectedOpinionIndex") int opinio
@ApiMethod(name="updateContact", path = "updateContact", httpMethod = "GET")
public OpinionModel updateEmployeeTitle(@Named("id") Long id,@Named("selectedOpinionIndex") int opinionIndex) {
PersistenceManager pm = PMF.get().getPersistenceManager();
javax.jdo.Transaction tx = pm.currentTransaction();
pm.currentTransaction().begin(); // <-------
OpinionModel e;
try {
e = pm.getObjectById(OpinionModel.class,id);
if (opinionIndex == 1) {
int foo = Integer.parseInt(e.opinion1ResultCount);
foo++;
e.opinion1ResultCount = Integer.toString(foo);
JDOHelper.makeDirty(e, e.opinion1ResultCount);
}else if (opinionIndex == 2) {
int foo = Integer.parseInt(e.opinion2ResultCount);
foo++;
e.opinion2ResultCount = Integer.toString(foo);
JDOHelper.makeDirty(e, e.opinion2ResultCount);
}
else if (opinionIndex == 3) {
int foo = Integer.parseInt(e.opinion3ResultCount);
foo++;
e.opinion3ResultCount = Integer.toString(foo);
JDOHelper.makeDirty(e, e.opinion3ResultCount);
}
else if (opinionIndex == 4) {
int foo = Integer.parseInt(e.opinion4ResultCount);
foo++;
e.opinion4ResultCount = Integer.toString(foo);
JDOHelper.makeDirty(e, e.opinion4ResultCount);
}
else {
System.out.println("Invalid selection");
}
pm.currentTransaction().commit(); // <-------
pm.makePersistent(e);
} finally {
if (tx.isActive())
{
// Error occurred so rollback the transaction
tx.rollback();
}
pm.close();
}
ApiResponse resp = new ApiResponse();
resp.responsecode = "SUCCESS";
resp.responseMessage = "Contact Updated ";
return e;
}
@ApiMethod(name=“updateContact”,path=“updateContact”,httpMethod=“GET”)
public OpinionModel updateEmployeeTitle(@Named(“id”)长id,@Named(“SelectedOpininIndex”)int opinionIndex){
PersistenceManager pm=PMF.get().getPersistenceManager();
javax.jdo.Transaction tx=pm.currentTransaction();
pm.currentTransaction().begin();//更新公共字段?这是什么世纪?使用setter来更新字段。当你这样做时,你没有参考日志上说的内容,我们必须猜测吗?@NeilStockton,现在是2014年。只有老古董才使用setter。正是这些人让java看起来很糟糕。