openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Abe White (JIRA)" <>
Subject [jira] Commented: (OPENJPA-568) Delete, re-insert and setting relationship in the same transaction results in
Date Fri, 11 Apr 2008 18:26:04 GMT


Abe White commented on OPENJPA-568:

As of revision 646082, I believe this patch is invalid.  The patch was to fix some of the
side effects of the original 245 fix, but this revision redid the 245 fix in a manner that
eliminated the offending side effects.  

My hunch is that the test mentioned in this report will now pass even without this patch.
 There are some esoteric configurations, though (like detached state being disabled) where
a test like this might still fail.  I believe the proper fix is to amend BrokerImpl.isDetached(Object)
to pass the OID_NODELETED flag when it makes its call to find(...).

> Delete, re-insert and setting relationship in the same transaction results in 
> ------------------------------------------------------------------------------
>                 Key: OPENJPA-568
>                 URL:
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: kernel
>    Affects Versions: 1.1.0
>         Environment: This problem is reported with OpenJPA version: 
> $ java org.apache.openjpa.conf.OpenJPAVersion 
> OpenJPA 1.1.0-SNAPSHOT 
> version id: openjpa-1.1.0-SNAPSHOT-r420667:634150 
> Apache svn revision: 420667:634150 
> Windows XP 
> os.version: 5.1 
> os.arch: x86 
> java.version: 1.6.0_05 
> java.vendor: BEA Systems, Inc. 
>            Reporter: Sandeep Shrivastava
>             Fix For: 1.1.0
>         Attachments: openjpa-1.1.0-SNAPSHOT-r420667.634150.patch
>   Original Estimate: 24h
>  Remaining Estimate: 24h
> The test deletes and instance and creates another with the same primary keys and encounters
an exception while making the new one persistent.
> Here is the snippet from the test code:
>         pm.currentTransaction().begin();
>         MappingTest2 test2c = new MappingTest2();
>         test2c.setPk1(test2b.getPk1());
>         test2c.setPk2(test2b.getPk2());
>         pm.deletePersistent(test2b);
>         test4.getNManyMap().put("key2", test2);
>         test4.getManyManyMap().remove(test2b);
>         test4.getManyManyMap().put(test2, test2);
>         pm.makePersistent(test2c);
>         test4.setInverseOneOne(test2c);
>         MappingTest4 test4c = new MappingTest4();
>         test4c.setInverseOwnerOneOne(test2c);
>         test2c.setOneOneOwner(test4c);
>         pm.makePersistent(test4c);
>         pm.currentTransaction().commit();
> The problem with this issue was that the JDO PersistenceManager. makePersistent() is
failing with the following exception:
> [testlogic] <openjpa-1.1.0-SNAPSHOT-r420667:634150 nonfatal user error>
> kodo.jdo.UserException: Operation attempted on a deleted instance.
> [testlogic] FailedObject: kodo.jdbc.meta.MappingTest2-3::4
> [testlogic] 	at org.apache.openjpa.kernel.PCState.error(
> [testlogic] 	at 
> org.apache.openjpa.kernel.PDeletedState.beforeOptimisticWrite(
> [testlogic] 	at 
> org.apache.openjpa.kernel.StateManagerImpl.dirty(
> [testlogic] 	at 
> org.apache.openjpa.kernel.StateManagerImpl.settingObjectField(
> [testlogic] 	at 
> org.apache.openjpa.kernel.AttachStrategy.attachField(
> [testlogic] 	at 
> org.apache.openjpa.kernel.VersionAttachStrategy.attach(
> [testlogic] 	at 
> org.apache.openjpa.kernel.AttachManager.attach(
> [testlogic] 	at 
> org.apache.openjpa.kernel.VersionAttachStrategy.attachInPlace(
> [testlogic] 	at 
> org.apache.openjpa.kernel.VersionAttachStrategy.attachFieldsInPlace(
> [testlogic] 	at 
> org.apache.openjpa.kernel.VersionAttachStrategy.attach(
> [testlogic] 	at 
> org.apache.openjpa.kernel.AttachManager.attach(
> [testlogic] 	at 
> org.apache.openjpa.kernel.AttachManager.attach(
> [testlogic] 	at 
> org.apache.openjpa.kernel.BrokerImpl.attach(
> [testlogic] 	at kodo.kernel.KodoBroker.attach(
> [testlogic] 	at 
> org.apache.openjpa.kernel.DelegatingBroker.attach(
> [testlogic] 	at 
> kodo.jdo.PersistenceManagerImpl.makePersistent(
> [testlogic] 	at 
> kodo.jdbc.kernel.TestFlush.testDeleteAndReInsert(
> Synopsis:
> When the second call to pm.makePersistent(test2c) is made it is not attached correctly.
The effect of the prior pm.deletePersistent(test2b) which deletes the object with the same
key is kept in the persistence context and hence when a relation is established with the deleted
entity the third pm.makePersistent(test4c) call throws the above exception.
> The fix that I have is to correct the logic in the org.apache.openjpa.kernel.VersionAttachStrategy.attach()
method where it tries to make a determination of whether this is a new object by also checking
whether the existing entity is deleted or not. And that fixes the problem. I will attach it
as a patch shortly.
> Thanks
> Sandeep

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message