1

在我的实体中添加这个嵌入字段后,我遇到了一个异常:

@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);

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

4

0 回答 0