[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5303) @Cachable has no effect

Julien Kronegg (JIRA) noreply at atlassian.com
Sat Nov 26 18:09:22 EST 2011


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5303?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=44439#comment-44439 ] 

Julien Kronegg commented on HHH-5303:
-------------------------------------

Hi Steve,

I had a similar issue on JBoss AS7 (default provider=Hibernate4) with {{@Cacheable}} on a JPA entity and the property {{<property name="javax.persistence.sharedCache.mode" value="ALL"/>}} (or any other value) in {{persistence.xml}}: the L2 entity cache does not work.

But if you use {{<shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>}} in the {{<persistence-unit>}} tag instead of the {{javax.persistence.sharedCache.mode}} property, and add the property {{<property name="hibernate.cache.use_second_level_cache" value="true"/>}}, the L2 entity cache works. See [my answer to Paul Bakker's post|https://forum.hibernate.org/viewtopic.php?p=2450594#p2450594].

So maybe that's not the {{@Cacheable}} annotation which does not work, but the {{javax.persistence.sharedCache.mode}} property.


> @Cachable has no effect
> -----------------------
>
>                 Key: HHH-5303
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5303
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: caching (L2), entity-manager
>    Affects Versions: 3.5.2
>         Environment: Tested on HSQL (included in testcase) and MySQL database
>            Reporter: Paul Bakker
>         Attachments: testcase.zip
>
>
> The JPA 2.0 @Cachable annotation has no effect at all. Just putting @Cachable on a class is not enough to enable caching. You must also configure a concurrency strategy with either @Cache or a hibernate.ejb.classcache setting in persistence.xml. 
> If those settings are in place, @Cacheble still has no effect. Entities are cached, but @Cachable(false) doesn't change this behavior. 
> I included a Maven example project that tests this behavior. The project has two profiles to switch between Hibernate and EclipseLink:
> mvn -P hibernate clean test
> mvn -P eclipselink clean test

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list