我无法使用下面的 JDO Score 类创建多图索引。如果我用 Object[] 代替 Score 一切正常。我认为问题是 Score 类不可序列化?我在 Score 课程中遗漏了什么?
分数等级:
@PersistenceCapable(identityType=IdentityType.APPLICATION, detachable="true")
@javax.jdo.annotations.Version(strategy=VersionStrategy.VERSION_NUMBER,column="VERSION",
extensions={@Extension(vendorName="datanucleus", key="field-name",value="version")})
public class Score implements Serializable {
private static final long serialVersionUID = -8805789255398748271L;
@PrimaryKey
@Persistent(primaryKey="true", valueStrategy=IdGeneratorStrategy.IDENTITY)
private Key id;
private Long version;
@Persistent
private String uid;
@Persistent
private Integer value;
}
多图索引:
List<Score> rows = new ArrayList(scores);
Multimap<Key, Score> grouped = Multimaps.index(rows,
new Function<Score, Key>() {
public Key apply(Score item) {
return (Key) item.getObjKey();
}
});