Native EclipseLink: enable second level cache for some objects
Our project uses the "old" (non-JPA) version of EclipseLink. These mappings are configured using the Workbench application (which generates XML configuration files and some Java code).
What we see in the workbench tool: it looks like for all objects, the cache of which is enabled with the Shared isolation level (default).
What we see in the application: no entity is cached
What we need: Enable second-level caching for only a few objects
EDIT
Configuration in Workbench EclipseLink:
Generated XML config:
[...]
<refresh-cache-policy/>
<caching-policy/>
[...]
Generated project code:
// ClassDescriptor Properties.
descriptor.useSoftCacheWeakIdentityMap();
descriptor.setIdentityMapSize(100);
descriptor.useRemoteSoftCacheWeakIdentityMap();
descriptor.setRemoteIdentityMapSize(100);
descriptor.setReadOnly();
descriptor.setAlias("SomeAlias");
// Cache Invalidation Policy
TimeToLiveCacheInvalidationPolicy policy = new TimeToLiveCacheInvalidationPolicy(1000);
policy.setShouldUpdateReadTimeOnUpdate(false);
descriptor.setCacheInvalidationPolicy(policy);
// Query Manager.
descriptor.getQueryManager().checkCacheForDoesExist();
+3
source to share