| A couple oddities here I want to mention:
- The @Cache annotation's java documentation specifically states that it should be used on the root-entity of the entity hierarchy. In your use case this would mean it should belong on Base rather than CacheOnJoinedInheritance.
- Then in order to influence how @Cache gets interpreted the javax.persistence.sharedCache.mode needs to be specified. This should be able to be specified in persistence.xml or part of your test case configuration.
By specifying the property in the test configuration, as follows:
configure(c -> c.setProperty(AvailableSettings.JPA_SHARED_CACHE_MODE, SharedCacheMode.ENABLE_SELECTIVE ) );
and modified your entities as follows:
@Entity
@Polymorphism(type = PolymorphismType.EXPLICIT)
@Inheritance(strategy = InheritanceType.JOINED)
@Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
public abstract class Base extends DatabaseEntity {
...
}
@Entity
@Cacheable
public class CacheOnJoinedInheritance extends Base {
...
}
And your test case then passes. Steve Ebersole, have I missed anything here wrt how this should be wired up under 5.3 that should be added here? |