JDO 没有字段被确定为主键字段

JDO no fields have been identified as primary key fields

我最近开始看到 JDO 错误,例如

Class X has been specified with an object-id class javax.jdo.identity.StringIdentity yet no fields have been identified as primary key fields.

我的 类 使用 javax.persistence.Id 注释,例如:

@Id
final private String key;

原来这是由于将关键字段标记为final。要修复,只需将声明更改为如下所示:

@Id
private String key;

留在这里,造福子孙后代!