3 Replies Latest reply on May 6, 2003 6:52 AM by sys user

    read-only mode with CMP entity beans?

    sys user Master

      Hi,

      my design goal is the following:

      -a CMP entity bean has a findAll method
      -a session bean uses this findAll method and usually finds 1000-10000 entities
      -these entities are converted into valueObjects
      -a collection of these valueObjects is transmitted to the client.

      When I did this I found out, that when the session bean method finishes the ejbStore methods of all the 1000-10000 entity beans are called. This is logic but unneccessary in my case.
      So I assume there has to be a read only mode for CMP entity beans which avoids the time consuming ejbStore-calls.
      But where is it?

        • 1. Re: read-only mode with CMP entity beans?
          Adrian Brock Master

          jboss.xml

          Something like

          <enterprise-beans>
          ...

          <ejb-name>Whatever</ejb-name>
          <method-attributes>

          <method-name>get*</method-name>
          <read-only>true</read-only>

          </method-attributes>

          Regards,
          Adrian

          • 2. Re: read-only mode with CMP entity beans?
            jjclose Newbie


            1) you might look at the methods makeClean and makeDirty, which cause ejbStore to get called. i seem to remember being able to override a method to prevent the store from being called.

            2) On a different subject, I saw your post reply to one of my questions about the Template project. have you been able to get the template project working as-is (i.e. with same basic classes)? If you have, would it be possible for you to send me a tar or zip of the whole project? I can't get it working for the life of me. my email is close@cafenoir.com . thanks for any help.

            • 3. Re: read-only mode with CMP entity beans?
              sys user Master

              Thanks for the replies!

              I have a few problems with the suggested solutions.
              What I do is kind of a feasibility study. That means I try to find out how a certain application could be redesigned/reimplemented in a J2EE environment.
              If the decision would be for a J2EE solution then there would be 2 possibilities how the product is used:

              a) Our application as a stand alone product
              or
              b) Our application integrated with other enterprise software modules that our customer uses in a J2ee environment.
              In case a) my favorite solution would be jBoss.
              But if the customer uses e.g. IBM web's fear ;-) then any jBoss specific feature would be deadly.
              Later in the product lifecycle (performance tuning, etc.) that is maybe acceptable but not in the stage of the feasibility study.

              On top of that:
              As I understand it (and it's easily possible that that is wrong) you can declare a get method in the entity bean as "read only" or you can declare the whole entity bean as "read only".
              But both cases do not match my needs.
              Because as I explained in my earlier posting we use value objects to transfer the data to (fat) clients.
              The underlying entities change rarely, but they DO change. So to declare the entity "read-only" is not working.
              In the case of the findAll method a session bean calls the findAll method of the entity. The session bean gets a collection of all entities.
              Then the session bean creates a collection of the appropriate value object class and fills it with the data from the entity beans. When that method finishes the EJB collection is destroyed. And because the entity beans are not "read only" all EJBs in the collection synchronize with the db. And that's my problem :-((

              But I think there has to be a clean solution to that (common) problem. And I will look deeper into this (including the "makeClean" method).