2 Replies Latest reply on Mar 6, 2005 5:15 AM by Christian Pietsch

    How to use 2nd level cache?

    Christian Pietsch Newbie

      Good morning,
      anybody can give me a hint how to use jcache or any other caching implementation as transparent 2nd-level-cache for entity-objects in ejb3?


        • 1. Re: How to use 2nd level cache?
          Bill Burke Master

          plug in a 2nd level cache the same way you would for regular hibernate. There is a default hibernate.properties in the ejb3.deployer/META-INF directory. If you want to override these values, just create a hibernate.properties within your foo.ejb3/META-INF or foo.ear/META-INF packaged deployment.

          • 2. Re: How to use 2nd level cache?
            Christian Pietsch Newbie

            Bill, thanks for your answer. I do have a working separate hibernate.properties in my ejb3-archive but I don't know how to enable caching for classes within this file. I have read the FAQ on hibernate.org and the relevant chapters in Hibernate in Action and found the following statement:

            In FAQ (http://www.hibernate.org/117.html#A32)

            Is the second-level cache enabled by default?
            No entities or collections will be cached in the second-level cache unless you supply <cache> elements in the mapping files or <class-cache> and/or <collection-cache> elements in hibernate.cfg.xml, even when EHCache or some other cache provider is configured.

            As the mapping files are generated in your implementation this seems to be a problem. Is there a simple workaround I haven't seen?