GAE/JPA/DataNucleus: Strange exception while tryin

2019-08-11 03:03发布

I'm getting an exception after I added this embedded field in my entity:

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

This guy is very simple:

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

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

When I try to merge my modifications I get the following exception:

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...

I don't think there's anything to do, but I had to use JDOHelper.makeDirty before merging the entity for it to perceive that I modified scoutBuffer:

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

As you can see commented in the code, I tried the workaround described here, without success. Strange thing is that is from 2009... I'm using GAE 1.7.0, by the way. Also, I tried cleaning/re-enhancing the datamodel.

0条回答
登录 后发表回答