我正在使用 datanucleus 3.2.5 / JDO 将对象持久化到 MongoDB 数据库。
在尝试保留一张列表地图时,我遇到了以下异常:
RuntimeException: json can't serialize type [list element type here]
一些示例代码:
@PersistenceCapable
public class SomeClass {
private Map<String, List<SomeOtherClass>> myAttribute;
// ...
}
@PersistenceCapable(embeddedOnly="true")
public class SomeOtherClass {
private String attribute;
// ...
}
我可以解决这个问题,将嵌入属性注释为@Serialized
,但我更喜欢更优雅的方式。
我错过了什么吗?有没有更好的方法来解决这个问题?