Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
3.1M2
-
None
Description
One more eye sore in the ObjectContext API is localObject method. While it is an important API for the Cayenne users to locate the copies of their objects between contexts, it is also used by Cayenne internal code to find-or-create objects for ObjectId or to transfer objects from parent to child contexts (either the same VM or via ROP).
The goal of this task is to separate the internal Cayenne concerns from the public API. I contend that the only API that needs to be exposed publicly is something like this:
/**
- Provides a copy of 'objectFromAnotherContext' local to this context, creating and registering a local hollow object if needed.
- 'objectFromAnotherContext' parameter must not be NEW or TRANSIENT, i.e. it must have a non-temporary ObjectId pointing
- to a row in the DB. Otherwise an Exception is thrown.
*/
T localObject(T objectFromAnotherContext)
A usercase where a user has no object, but has an ObjectId can be handled via an ObjectIdQuery or better - via Cayenne.objectForPK(ObjectContext, ObjectId). All other usecases are deemed internal to Cayenne. So Cayenne core should be refactored to stop relying on 'localObject' internally.