Native EclipseLink: enable second level cache for some entities

Viewed 269

In our project, the "old" native (non-JPA) version of EclipseLink is still in use. The 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 entities the cache is enabled with isolation level Shared (default).

What we see in the application: no entity gets cached

What we want: Enable second level caching for some few entities only

EDIT

Config in EclipseLink Workbench:

enter image description here

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();
1 Answers
Related