【问题标题】:objectify - java.lang.IllegalStateException: At path ** Expected property valueobjectify - java.lang.IllegalStateException: At path ** 预期的属性值
【发布时间】:2014-06-24 04:50:59
【问题描述】:

我有一个包含 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 将 Data 实体保存到 datastore 时,出现以下异常(我目前正在使用 objectify 4.0b3 ):

com.googlecode.objectify.impl.cmd.SaverImpl.entity(SaverImpl.java:33) 在 test.BattleResponseTest.populateBattlesData(BattleResponseTest.java:172) 在 test.BattleResponseTest.testGetAllBattles_checkBattleIds(BattleResponseTest.java:185) 在sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在 java.lang.reflect.Method。调用(Method.java:601)在 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) 在 org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) 在org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) 在 org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) 在 org.junit.internal.runners.statements。 RunBefores.evaluate(RunBefores.java:28) at 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。在 org.junit.runners.runChildren(ParentRunner.java:229) 在 org.junit.runners 在 org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) 运行(ParentRunner.java:231)。 ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at org.eclipse .jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) 在 org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) 在 org.eclipse.jdt.internal .junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) 在 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) 在 org.eclipse.jdt.internal.junit.runner .RemoteTestRunn er.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) 原因:java.lang.IllegalStateException:在路径'dataMap.1.turns ':预期的属性值,在 com.googlecode.objectify.impl.Transmog 的 com.googlecode.objectify.impl.Path.throwIllegalState(Path.java:134) 处获得 {turnId={1}, score={135000}}。 populateFields(Transmog.java:402) 在 com.googlecode.objectify.impl.Transmog.populateFields(Transmog.java:430) 在 com.googlecode.objectify.impl.Transmog.populateFields(Transmog.java:430) 在 com.googlecode .objectify.impl.Transmog.populateFields(Transmog.java:430) 在 com.googlecode.objectify.impl.Transmog.save(Transmog.java:364) 在 com.googlecode.objectify.impl.Transmog.save(Transmog.java :100) ... 30 更多

请帮忙?

【问题讨论】:

    标签: google-cloud-datastore objectify


    【解决方案1】:

    Objectify v4 用于存储嵌入式集合的格式不适合存储嵌套在集合内的集合。如果您迁移到 v5,您将能够做到这一点。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-20
      • 1970-01-01
      • 1970-01-01
      • 2019-09-23
      • 2020-12-27
      • 2014-11-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多