5 Replies Latest reply on Apr 2, 2008 6:04 PM by jamesjmp

    Caching

      hi,
      I have a war (NO ear) seam-gened app using Seam 2.0.1.GA with war.
      I want to cache the contents of some of my database tables. As I´ve used seam-gen I have pojos that implements serializable
      that are related to that tables.
      Due to the database design, this pojos have plenty of set members (foreign keys are their cause), and I do NOT want to cache
      that fields.


      My issues for the data to be cached in this app are the following:
      - Data is to be shared among all users, it´s no specific session or user information
      - Data would be changed from time to time.
      - Cache should be updated once a day (or other defined period)
      - if possible, cache should be updated when there is a change in the database (not mandatory but would be a plus)


      I´ve read about EHCache, OsCache and JBossCache (core and Pojo), and I know there are other ways and products.


      At first I thought about using JBoss Pojo Cache, but the fact of having my pojos implementing serializable and the
      recommendation of the pojo cache docs of not using it with serializables has made me think it over again. Maybe the solution is using PojoCahce but nit with the seam-gened pojos but new-coded ones just with the fields I require?


      what do you advise me?
      thank you!


        • 1. Re: Caching
          tom_goring

          Use a standard EJB3 cache....


          Read up on @Cache


          e.g.


          @Entity
          @Table(name="company")     
          @Cache(usage=CacheConcurrencyStrategy.TRANSACTIONAL)
          


          • 2. Re: Caching
            christian.bauer

            This is actually @org.hibernate.annotations.Cache and has nothing to do with the EJB 3.0 standard. Read up on Hibernate second-level cache.

            • 3. Re: Caching

              Should I add a hibernate.cfg.xml to my seam project?
              otherwise, where should I add configuration like this:


              <session-factory>
                        <property name="hibernate.cache.provider_class">
                             org.hibernate.cache.EHCacheProvider
                        </property>
                   </session-factory>
              



              thanks in advance!

              • 4. Re: Caching
                christian.bauer

                This should go into persistence.xml in almost all cases. And you are in for a lot of trouble if you are going to do this ad hoc without reading up on it first.

                • 5. Re: Caching

                  thank you, and don´t worry I´ll read up on it!!