1 Reply Latest reply on Apr 20, 2005 6:42 PM by Satish Satish

    CMP - Local EJBs are making distinct calls to the database w

    Satish Satish Newbie

      I am using JBoss 3.2.5 (xdoclet based) with MySQL 4.1
      I have been load testing my application and have found that separate database calls are being made to retrieve the persistent field values.
      The ejb finders are making a single call to retrieve all the field values.
      Is there a way to make the local entity bean retrieve all the filed values at once and use them instead of making separate calls to the database?

      For example,

      makes distinct database calls
      select name from customer where (customerId=?)
      select address from customer where (customerId=?)

      Instead I would like the ejb container to make a single call
      select customerId, name, address, etc from customer where (customerId=?)

        • 1. Re: CMP - Local EJBs are making distinct calls to the databa
          Satish Satish Newbie

          More info:

          I am using CMRs. and value objects using the @ejb.relation and @ejb.value-object xdoclet tags.

          * @ejb.relation
          * name="customer-user"
          * role-name="CustomerUserRelationshipRole"
          * cascade-delete="no"
          * target-ejb="User"
          * target-role-name="UserCustomerRelationshipRole"
          * target-cascade-delete="no"
          * @ejb.value-object
          * compose="CustomerVO"
          * compose-name="Customer"
          * members="CustomerLocal"
          * members-name="CustomerLocal"
          * relation="external"
          public abstract CustomerLocal getCustomer();

          The generated CustomerCMP has the method implemented as

          public CustomerVO getCustomerVO()
          customerVO = new CustomerVO ();
          customerVO .setName( getName() );
          customerVO .setAddress( getAddress() );
          catch (Exception e)
          throw new javax.ejb.EJBException(e);

          return customerVO;

          And as I was profiling the application, it made separate calls to the database to get the name and address fields.
          So if there are about 10 fields in the table, it would make 10 calls instead of one sql statement to retrieve all the field values.

          Can anyone solve this problem?