DataNucleus JIRA is now in read-only mode. Raise any new issues in GitHub against the plugin that it applies to. DataNucleus JIRA will remain for the foreseeable future but will eventually be discontinued
Issue Details (XML | Word | Printable)

Key: NUCCORE-561
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Andy Jefferson
Reporter: Fernando Padilla
Votes: 0
Watchers: 1

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

findObject should have extension to not validate objects that come from cache

Created: 26/Jul/10 04:44 AM   Updated: 20/Oct/10 09:29 AM   Resolved: 21/Sep/10 12:27 PM
Component/s: Queries
Affects Version/s: None
Fix Version/s: 2.2.0.m2

 Description  « Hide
In our app we have over-ridden the findObject(Object id, boolean validate, boolean checkInheritance, String objectClassName) method, so that it would not actually validate objects that come from the cache. If the cache is maintained properly and trusted, then it should never have an object that does not exist in the database. If that is the case, then re-validating every object from cache is just a huge waste of database resources. :)

We simply changed the "if (validate)" near the bottom of the function to be "if (validate && !fromCache)" and have seen a great performance improvement.

Sort Order: Ascending order - Click to sort in descending order
Chris Colman added a comment - 31/Jul/10 03:54 AM
This sounds like an awesome optimization. I suggested something like this a long way back. If your system is running with a single L2 cache then why not trust it rather than the database as all objects and object updates must go through the cache. Maybe that's the problem... object updates... maybe they aren't flushed to the L2 cache yet - but that could be fixed with a cache eviction of updated L2 objects.

Andy Jefferson added a comment - 20/Sep/10 01:40 PM
DN does what the spec says, explicitly. If the user requests "validate" then it validates. Obviously this can be a vendor extension, and users can propose a patch

Fernando Padilla added a comment - 20/Sep/10 06:15 PM
I say let bygones be bygones, but please; let's add at least an option to have it work this way. :) Thank you! :)


Andy Jefferson added a comment - 21/Sep/10 12:27 PM
Default behaviour will always be strict JDO (at least until we have persistence profiles added). Users can now set the persistence property
(with default of true).

Fernando Padilla added a comment - 21/Sep/10 06:35 PM
actually, not sure how to reopen this bug.. but there is a bug in your fix. :) The correct test within ObjectManagerImpl should be, to skip validation only if it's fromCache and performValidation is false.

if (validate && (performValidation || !fromCache))


if (validate && performValidation)

Index: core/trunk/src/java/org/datanucleus/
--- core/trunk/src/java/org/datanucleus/ (revision 10517)
+++ core/trunk/src/java/org/datanucleus/ (revision 10518)
@@ -2766,7 +2766,8 @@
- if (validate)
+ boolean performValidation = (omf.getBooleanProperty("datanucleus.findObject.validateWhenCached"));
+ if (validate && performValidation)
             // User requests validation of the instance so go to the datastore to validate it
             // loading any fetchplan fields that are needed in the process.