Hi.
I'm wiring my JPA PU using Spring only (no persistence.xml)
as I have a PU spread over different modules, in a
JSE-environment. I use Spring's
LocalContainerEntityManagerFactoryBean with packagesToScan
property to scan the classpath for my annotated classes.
I'm then trying to cache some entities using
javax.persistence.sharedCache.mode=ENABLE_SELECTIVE semantics,
that is; I don't want caching on anything that doesn't have
the JPA-2.0's @Cacheable(enabled = true) annotation. I'm
unable to achieve this however. EL seems to enable caching for
everything as default so I'm using this property to disable
it:
(JPA-properties set by Spring):
<prop
key="eclipselink.cache.shared.default">false</prop>
<prop
key="javax.persistence.sharedCache.mode">ENABLE_SELECTIVE</prop>
Disabling the cache seems to work but enableing the
ENABLE_SELECTIVE-semantics setting the
javax.persistence.sharedCache.mode property seems to have no
effect.
The docs I can find and Google all suggest setting the
persistence.xml property
<shared-cache-mode>NONE</shared-cache-mode>. This
should have the same effect as setting the JPA-property
javax.persistence.sharedCache.mode=ENABLE_SELECTIVE as far as
I can tell.
Can anyone shed some light on what I'm doing wrong and if
my setup is supposed to work?
Not specifying the eclipselink.cache.shared.default property
at all and just having
javax.persistence.sharedCache.mode=ENABLE_SELECTIVE results in
everything being cached, also entities not annotated with
@Cacheable.