Issue Details (XML | Word | Printable)

Key: NUCCORE-970
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Andy Jefferson
Reporter: Andy Jefferson
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
DataNucleus Core

Persist of N side of 1-N bidir with detached owner (when using datastore id and IDENTITY) causes persist of 2 objects rather than 1!

Created: 20/Dec/12 10:25 AM   Updated: 31/Dec/12 07:58 PM   Resolved: 20/Dec/12 11:58 AM
Component/s: Persistence
Affects Version/s: 1.0.5, 1.1.6, 2.0.5, 2.1.4, 2.2.4, 3.0.11, 3.1.3
Fix Version/s: 3.1.4, 3.2.0.m2


 Description  « Hide
See the test test.jdo.general AttachDetachTest "testAttachOneManyBidirFromNewManySide". This creates an owner object and detaches it. It then creates an element, and sets its owner to the detached owner (and adds the new element to the detached owner collection). It then calls makePersistent on the element. This causes

INSERT INTO ANIMAL ("NAME",FARM_FARM_ID_OID) VALUES (<'Porky'>,<1>)
UPDATE ANIMAL SET FARM_FARM_ID_OID=<1> WHERE ANIMAL_ID=<1>
INSERT INTO ANIMAL ("NAME",FARM_FARM_ID_OID) VALUES (<'Porky'>,<1>)
UPDATE ANIMAL SET FARM_FARM_ID_OID=<1> WHERE ANIMAL_ID=<2>

When the farm is retrieved it only shows 1 element so the test in SVN passes, but this is only due to how the test is written, whereas there are actually 2 ANIMAL objects in the datastore

Andy Jefferson made changes - 20/Dec/12 10:46 AM
Field Original Value New Value
Summary Persist of N side of 1-N bidir with detached owner (when using datastore id) causes persist of 2 objects rather than 1! Persist of N side of 1-N bidir with detached owner (when using datastore id and IDENTITY) causes persist of 2 objects rather than 1!
Andy Jefferson added a comment - 20/Dec/12 11:58 AM
SVN trunk and branches/3.1 fix this with a check on the ObjectProvider "activity" setting when makePersistent is called; if already set then is already being made persistent

Andy Jefferson made changes - 20/Dec/12 11:58 AM
Status Open [ 1 ] Resolved [ 5 ]
Assignee Andy Jefferson [ andy ]
Fix Version/s 3.1.4 [ 11800 ]
Fix Version/s 3.2.0.m2 [ 11780 ]
Resolution Fixed [ 1 ]
Andy Jefferson made changes - 31/Dec/12 07:58 PM
Status Resolved [ 5 ] Closed [ 6 ]