【发布时间】:2014-03-11 18:03:19
【问题描述】:
我正在尝试使用 Objectify 4(和 GAE SDK 1.9.0)将地图嵌入到实体中。
docs (here) 显示如下内容:
@Embed
class LevelTwo {
String bar;
}
@Entity
class EntityWithEmbeddedCollection {
@Id Long id;
List<LevelOne> ones = new ArrayList<LevelOne>();
}
所以我首先尝试做同样的事情,但使用的是 HashMap。当我尝试保存实体时,这会导致运行时错误。
然后我读到了 @EmbedMap,这是 ofy 的最新成员。所以我尝试了以下格式:
class LevelTwo {
Integer one;
Boolean bee;
}
class EntityWithEmbeddedCollection {
@Id Long id;
@EmbeddedMap
Map<Long, LevelTwo> ones = new HashMap<Long, LevelTwo>();
}
我也尝试过将 LevelTwo 作为内部静态类和其他一些变体,但我总是得到:
com.googlecode.objectify.SaveException:
Error saving com.myapp.UserInfoSvr@96: items: java.util.HashMap is not a supported property type.
at com.googlecode.objectify.impl.Transmog.save(Transmog.java:105)
有什么建议吗?
【问题讨论】:
标签: java google-cloud-datastore objectify