0 Replies Latest reply on Apr 9, 2009 3:56 AM by carstenrudat

    Basis question on 2nd level caches of ejb3 entities

      Hi all,

      I'm afraid, I have to ask a basis question...
      I set up JBossCache as a 2nd-level cache for (hibernate) my ejb3-entities. I can see, that the cache is filled, by monitoring the mbean in jmx-console.

      Now my question: A stateless (!) sessionbean uses an transactional EntityManager. A client calls sessionBean#findEntityWithId(...), then the SLSB returns (and with that ends the transaction). After that the client calls the same method with same parameters (i.e. "load" the same entity by its ID).
      Will the second call hit the cache or will the database accessed, because "after the first transaction, the cache will be discarded"?

      In other words, does the 2nd-level cache lives longer than transaction boundaries?

      Thanks for (this basic) information.
      Carsten