3 Replies Latest reply on Oct 16, 2002 9:54 AM by juha

    Caching entity beans?!?

    davout

      A newbie question about caching entity beans...

      In my design I have an entity bean class that is going to be referenced so often by session bean instances that I'm wondering whether the normal entity bean 'find()' approach is going to be fast enough.

      Does EJB support any form of entity bean caching to keep entity bean instances in memory for continuous data access?


        • 1. Re: Caching entity beans?!?
          joelvogt

          jboss will do a fair bit of this cacheing behind the scenes for you. However if that will be fast enough will depend on your situation. A good idea is to only get the data from the ejb once, via say, a getValueObject() method. Theres plenty of docs around if your keen to really get into it

          • 2. Re: Caching entity beans?!?
            davout

            Sorry... I don't follow...

            Let's assume that I have a stateless session bean that a consumer is using to exercise some business logic.

            This stateless session bean needs to use an entity bean. But this session bean is going to be called at a such a frequency that it would make sense to have the entity bean always available in memory for rapid access.

            If I was writing this as a non-EJB session I'd probably make the enity bean a static class data field.

            Rather than hoping that JBoss do this sort of thing for me, is there a specific technique I can employ to ensure that the entity bean is always cached?

            • 3. Re: Caching entity beans?!?

              The entity is cached in case of commit option A (see the spec). This works if all your access to the underlying database is executed through the app server. JBoss also implements a commit option D that allows refresh from db upon a given interval. See the JBoss documentation for more info on this option.

              These assuming the data your accessing is not read-only.