GAE / JPA / DataNucleus:尝试持久化实体时出现奇怪的异常(IllegalArgumentException:out of field index:-1)

时间:2012-08-23 17:17:50

标签: google-app-engine jpa google-cloud-datastore datanucleus

我在实体中添加了这个嵌入字段后出现异常:

@Entity
public class Team extends DataObject
{
    @Embedded
    private TeamEvolution teamEvolution = new TeamEvolution();

    // NEW FIELD:
    @Embedded
    // @AttributeOverrides({ @AttributeOverride(name = "buffer", column = @Column) })
    // @Enumerated
    private ScoutBuffer scoutBuffer;
 ...

这家伙很简单:

@Embeddable
public class ScoutBuffer 
{
    private static final int BUFFER_SIZE = 150;

    @Basic
    private List<String> buffer;
   ... // from here on there are only methods...

当我尝试合并修改时,我得到以下异常:

java.lang.IllegalArgumentException: out of field index :-1
    at com.olympya.futweb.datamodel.model.ScoutBuffer.jdoProvideField(ScoutBuffer.java)
    at org.datanucleus.state.JDOStateManagerImpl.provideField(JDOStateManagerImpl.java:2585)
    at org.datanucleus.state.JDOStateManagerImpl.provideField(JDOStateManagerImpl.java:2555)
    at org.datanucleus.store.mapped.mapping.CollectionMapping.postUpdate(CollectionMapping.java:185)
    at org.datanucleus.store.mapped.mapping.EmbeddedPCMapping.postUpdate(EmbeddedPCMapping.java:133)
    // etc, etc...

我认为没有任何事情要做,但我必须在合并实体之前使用JDOHelper.makeDirty才能感知到我修改了scoutBuffer

   team.getScoutBuffer().add(playerIds);
   JDOHelper.makeDirty(team, "scoutBuffer");
   em.merge(team);

正如您在代码中看到的那样,我尝试了here所述的解决方法,但没有成功。奇怪的是,那是从2009年开始......顺便说一下,我正在使用GAE 1.7.0。此外,我尝试清理/重新增强数据模型。

0 个答案:

没有答案