openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nasseria1 <>
Subject Setting entity cach on persistence.xml or @DataCache annotation?
Date Wed, 20 Oct 2010 13:32:03 GMT

Dear All,

We are using OpenJPA 1.2 on glassfish. We use entity caching to improve our
application performance. 
As you may know, there are two options to set cache settings in an
OpenJPA-based application: At persistence-level that use persistence.xml, we
just set DataCache there to enable entity caching in the whole application:
<property name="openjpa.DataCache" value="true"/>

and at entity-level that requires @DataCache annotation:

public class OpenJPACacheTest { ... }

The first question is which method has the highest priority? Using xml or
annotation? Is annotation overrides cache settings in persistence.xml? For
e.g. if I enable cache on persistence.xml and disable it on entity level
using enabled=false, which setting is applied finally?

And the second question is about setting entity cache timeout in
persistence.xml. I found out setting cache time-out to evict an entity using
DataCache annotation is doable after a special time out expiration. We can
use timeout attribute from @DataCache annotation:

public class OpenJPACacheTest { ... }

But for now, can I set entity cache timeout on persistence.xml? And if the
answer is yes, which method has the highest priority again?

Thanks for any tips,
View this message in context:
Sent from the OpenJPA Developers mailing list archive at

View raw message