rzo1 opened a new pull request, #316: URL: https://github.com/apache/openjpa/pull/316
https://issues.apache.org/jira/browse/OPENJPA-3093 To write the delete row, `RelationFieldStrategy.delete()` called `fetchObjectField()` for every to-one relation, which loads an unloaded LAZY relation: one SELECT per removed instance and relation, only to get the foreign key value used to order the DELETE statements. For an unloaded field the foreign key value is already held as the intermediate value, so the related instance is now looked up in the persistence context instead. Loaded or changed relations use the old path, and so does the case where the related entity was removed and a new one with the same id was persisted in the same flush. SQL when removing 3 orders with 2 lines each: the SELECTs on PRODUCT (2) and CUSTOMER (1) are gone; only the SELECTs of the cascaded lines and the DELETEs remain. Tests (Derby): new `TestRemoveLazyRelation` (no extra SELECT; delete order with an unloaded relation; delete order when the related entity is replaced by a new instance with the same id). The first fails without the fix. The delete, relations, cascade, update, mapping, inheritance and detachment packages of openjpa-persistence-jdbc pass. Draft: the TCK runs on this branch first. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
