4.6. Putting It All Together
The following code excerpts show how to use the state interrogation methods and instance callbacks to debug common problems. A class is developed that serves as a helper to find out about the actual state of objects, number of objects in memory, objects per state, and so on. Because most JDO vendors don't provide methods to get information about a PersistenceManager's in-memory cache, it is quite handy to have a vendor-independent debug facility.
All the following methods can be found in the DebugStates.java source file.
The first method is a helper to get the memory ID of an object. A simple way to get an informal ID of an object is to call identityHashCode. Although this is not a unique ID, it works on common virtual ...
Get Core Java™ Data Objects now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.