我有以下来自Andreas Borglin的教程的代码:
@Override
public Model saveModel(Model model) {
System.out.println("model isDone: " + ((Task)model).getDone());
PersistenceManager pm = PMF.get().getPersistenceManager();
Model savedModel = null;
try {
savedModel = pm.makePersistent(model);
} catch (JDOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
pm.close();
}
System.out.println("savedModel isDone: " + ((Task)savedModel).getDone());
System.out.println("model isDone: " + ((Task)model).getDone());
return savedModel;
}
我创建测试实体时一切正常,但是一旦想要更新它们,布尔值不会改变。我的保存的"isDone"是"true",我想将其更改为"false",输出如下:
model isDone: false
savedModel isDone: true
model isDone: false
更改字符串或设置日期没有问题。该字段定义为:
@Persistent
private boolean isDone = true;
我也尝试过:
@Persistent
private Boolean isDone;
在这种情况下,isDone始终为“false”。