ObjectDB ObjectDB

Multiple Collection Fields not update correctly




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 {
            return true;
        } finally {
            if (em.getTransaction().isActive()) {


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


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


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



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


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


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

ObjectDB Support


To post on this website please sign in.