title: Enabling Hibernate second-level cache with JPA on JBoss 4.2
body: <p>What are the steps required to enable Hibernate's second-level cache, when using the Java Persistence API (annotated entities)? How do I check that it's working? I'm using JBoss 4.2.2.GA.</p>
  
  <p>From the Hibernate documentation, it seems that I need to enable the cache and specify a cache provider in <em>persistence.xml</em>, like:</p>
  
  <pre><code>&lt;property name="hibernate.cache.use_second_level_cache"
            value="true" /&gt; 
  &lt;property name="hibernate.cache.provider_class" 
            value="org.hibernate.cache.HashtableCacheProvider" /&gt; 
  </code></pre>
  
  <p>What else is required? Do I need to add <em>@Cache</em> annotations to my JPA entities?</p>
  
  <p>How can I tell if the cache is working? I have tried accessing cache statistics after running a Query, but <em>Statistics.getSecondLevelCacheStatistics</em> returns null, perhaps because I don't know what 'region' name to use.</p>