我有一个包含EmbedMap的下层实体,而EmbedMap又包含一个Embed对象。
@Entity
public class Data
{
@Id private long id;
private String name;
@EmbedMap Map<String, PlayerData> dataMap = Maps.newHashMap();
}
@Embed
public class PlayerData
{
private long playerId;
List<TurnData> turns = Lists.newArrayList();
}
@Embed
public class TurnData
{
private long turnId;
private long score;
}
当我尝试使用 Objectify 将数据实体保存到数据存储区时,我得到以下异常(我目前正在客观化 4.0b3 ):
在test.BattleResponseTest.testGetAllBattles_checkBattleIds(BattleResponseTest.java:185)的test.BattleResponseTest.populateBattlesData(BattleResponseTest.java:172)上的com.googlecode.objectify.impl.cmd.SaverImpl.entity(SaverImpl.java:33)at sun.reflect.NativeMethodAccessorImpl.invoke0(本地方法)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method。在org.junit.runl上的org.junit.runners.model.FrameworkMethod $ 1.runReflectiveCall(FrameworkMethod.java:45)调用(Method.java:601)org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)at at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)位于org.junit.internal.runners.statements的org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)。 RunBefores.evaluate(RunBefores.java:28)org.junit.runners.ParentRunner.runLeaf(ParentRu) nner.java:263)org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)org.junit.runners.ParentRunner $ 3。运行(ParentRunner.java:231)org.junit.runners.ParentRunner $ 1.schedule(ParentRunner.java:60)org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)org.junit.runners。在org.eclipse的org.junit.runners.ParentRunner.run(ParentRunner.java:300)的org.junit.runners.ParentRunner $ 2.evaluate(ParentRunner.java:222)的ParentRunner.access $ 000(ParentRunner.java:50) org.eclipse.jdt.internal的org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)上的.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)位于org.eclipse.jdt.internal.junit.runner的org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)的.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) .RemoteTestRunn er.run(RemoteTestRunner.java:390)at or.e.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)引起:java.lang.IllegalStateException:在路径&#39; dataMap。 1.turns&#39;:预期的财产价值,在com.googlecode.objectify的com.googlecode.objectify.impl.Path.throwIllegalState(Path.java:134)得到{turnId = {1},得分= {135000}} .impl.Transmog.populateFields(Transmog.java:402)at com.googlecode.objectify.impl.Transmog.populateFields(Transmog.java:430)at com.googlecode.objectify.impl.Transmog.populateFields(Transmog.java:430) )com.googlecode.objectify.impl.Transmog.populateFields(Transmog.java:430)at com.googlecode.objectify.impl.Transmog.save(Transmog.java:364)at com.googlecode.objectify.impl.Transmog。保存(Transmog.java:100)... 30多个请帮助?
答案 0 :(得分:2)
Objectify v4用于存储嵌入式集合的格式不适用于嵌套在集合内的存储集合。如果您迁移到v5,则可以执行此操作。