ObjectDB ObjectDB

Multiple Collection Fields not update correctly

#1

 

v2.8.8_2

I have an entity that has 2 collection fields:


@OneToMany(fetch = FetchType.EAGER)     

Collection position;     

@OneToMany(fetch = FetchType.EAGER)     

Collection rotation;

 

Now if I persist them so the values are:

position has values 1.0f, 2.0, 3.0

rotation has values 4.0f, 5.0, 6.0

 

This works fine. But when I load it from the database and set the values:

position has values 7.0f, 7.0, 7.0

rotation has values 8.0f, 8.0, 8.0

Merge it

 

        EntityManager em = getEM();
        try {
            em.getTransaction().begin();
            em.merge(myEntity);
            em.getTransaction().commit();
            return true;
        } finally {
            if (em.getTransaction().isActive()) {
                em.getTransaction().rollback();
            }
            em.close();
        }

 

now I look at the data, I get the following. I looked at my getters setters and they are fine, since persist works. But when updating(merging existing record) somehow the rotation overrides the position.

I can only have 1 field that is a Collection<Float>.

 

position has values 8.0f, 8.0, 8.0

rotation has values 8.0f, 8.0, 8.0

edit
delete
#2

This seems to happen only when the entity is linked to another entity and they both reciprocally do:

EntityB:

    @OneToOne(cascade = CascadeType.ALL)
    EntityA entityA;

 

EntityA:

    @OneToOne(cascade = CascadeType.ALL)
    EntityB entityB;

 

If I make only one of the cascade, then this bug does not occur anymore

edit
delete
#3

Could you please provide a one file test case that demonstrates this issue?

ObjectDB Support
edit
delete

Reply

To post on this website please sign in.