6 Replies Latest reply on Aug 17, 2004 5:15 AM by aloubyansky

    Entity bean caching

    neva

      Hi All,

      I bumped into a problem while working with caching. In an application I am developing, I defined 2 entity beans both referring to the same table in the db and each of them is in a different module (jar). Of course when I use caching, I face inconsistency bec. if I edit from one module, it is not reflected in the other since from jboss's point of view, they are 2 separate things. How do I overcome this?
      P.S: I need 2 entity beans representing the same table bec. I need that entity to have relationships with other entites from both jars and since I can't have relationships between beans not contained in the same jar, this seemed like the only thing to do.
      Suggestions?

        • 1. Re: Entity bean caching
          triathlon98

          Which commit option are you using?
          I think you can only use option C.

          Joachim

          • 2. Re: Entity bean caching
            neva

            well, I had to use Option C after failing to come up with a solution but this really weakened the advantage that caching offered to my application.
            This table (represented by the 2 beans) has many records thus making caching imperative!
            I need to get it back to Commit Option A :(

            • 3. Re: Entity bean caching
              triathlon98

              In that case, I think you better make sure all the entity beans are in one jar.

              Joachim

              • 4. Re: Entity bean caching
                neva

                well actually, I can't because I have to follow a specific design that makes all modules independent of each other and at the same time if used together, avoid inconsistency..

                what if I use jboss cache invalidation, would that do the trick? or do they still have to be in the same jar for it to work?

                • 5. Re: Entity bean caching
                  triathlon98

                  I am afraid this could result in race conditions. Would require serious load testing.

                  However, just making sure your transactions are not too small combined with commit option C would seem better/safer to me.

                  Joachim

                  • 6. Re: Entity bean caching
                    aloubyansky

                    You can use cache invalidation. Make sure the DB's isolation level is READ_COMMITTED.