New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object duplication after detach/makePersistent #75

Closed
tzaeschke opened this Issue Feb 7, 2016 · 1 comment

Comments

Projects
None yet
1 participant
@tzaeschke
Owner

tzaeschke commented Feb 7, 2016

Using detach can result in objects being duplicated:

  1. commit an object with setDetachAllOnCommit(true). Also keep a reference to the object, say o1.
  2. query the object. This will return the object, but as a separate instance. We now have the object twice in memory.
  3. Call makePersistent(o1). This will assign a new OID
  4. Commit. Now the object is twice in the database.

It is not clear what the JDO Spec saying about this. Clearly, it can be very confusing if object get duplicated. At least, the database is at least fundamentally consistent, because the new object gets a new OID. But is this the expected behaviour?

A test with the reference implementation (data nucleus 4.2 RDBMS/HSQL) shows very similar behaviour, except that now new ID is assigned, there a simply two objects with the same ID in the database.

This need probably to be raised with the JDO people.

@tzaeschke

This comment has been minimized.

Show comment
Hide comment
@tzaeschke

tzaeschke Apr 21, 2016

Owner

Apparently the behaviour is as intended. Once an object is loaded and detached, a follow-up query has no choice but creating (materializing) a second object with the same OID.

Owner

tzaeschke commented Apr 21, 2016

Apparently the behaviour is as intended. Once an object is loaded and detached, a follow-up query has no choice but creating (materializing) a second object with the same OID.

@tzaeschke tzaeschke closed this Apr 21, 2016

tzaeschke added a commit that referenced this issue Sep 17, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment