1 Reply Latest reply on Aug 6, 2004 4:50 AM by Alexey Loubyansky

    Caching of entity beans

    Oystein Aadland Newbie


      I'm trying to figure out how the caching for cmp entity beans works in JBoss. I had this (maybee naive) idea that if an entity bean was loaded the cmp engine would load this bean only once from the database (One time for each transaction for commit option B).

      This is the scenario:

      I repeatedly call a findBySomeParameter(xxx) within one transaction with the same parameters. So the result set is the same each time. The parameters are not the primary key.

      This results in db access for each find. So it obviously does not use the cache even if it sustains one.

      I'm using standard entity cmp 2.0 configuration with commit option B and read-ahead 100 on-load.

      I could of course cache this in my own application but isn't this what cmp should be good at? I do see that it can be difficult for the container to do this, but all this talk about the wonders of the EJB and caches has led me to believe that there where a solution to this.

      I would really apretiate if someone could explain this to me. How can I code my application to make any use of the bean cache?

      Best regards