Help Needed urgently

Discussions

EJB programming & troubleshooting: Help Needed urgently

  1. Help Needed urgently (6 messages)

    Here is the defination of the program which i m facing.

    My design goes something like this. A session bean's business method which is acessing the EntityBean to update the fields. Here i m not mentioning the transaction type for any of the bean's method. The underlyig table of the entity bean(CMP) is very huge having around 60-70 fields. Now when i m executing the biz method of the session bean which is updating some 20-30 fields of the bean this method takes more then a min. to complete execution. Later i found out that everytime a execute the a metod of the bean ejbLoad() as well as ejbStore() method of the entity bean gets called which is taking time since the table to be loaded is very huge.
    Is there some way like changing trans attrib, in which i can restrict this and make ejbStore() of the bean called only when the bizmethod i.e. actual transaction is over.

    Looking at this behaviour i have another question
    suppose in a method i m updating 10 fields of the bean that means i would be calling 10 setter methods if the ejbLoad and ejbStore is called after every method so if there is some error on the updation of the field # 5 does it properly rollback the previously updated values. The question is beacause it calles ejbStore after every method.

    Thanks
    Desperatly waiting for your reply
    Sachin
    sachinshah@hotvoice.com

    Threaded Messages (6)

  2. Help Needed urgently[ Go to top ]

    Use bulk accessors to get and set your feilds.
    See the patterens section for more details

  3. Help Needed urgently[ Go to top ]

    Hello Raghu

    I m not much experienced to EJB developement. so can you please help me how to use this bulk accessors.

    Thanks
  4. Help Needed urgently[ Go to top ]

    put db-is-shared to false to restrict calls to ejbload but only if u'r database is indeed not shared and write the code for isModified to store the contents only if the contents have changed from the previous value. This will restrict the calls to ejbStore.
  5. Help Needed urgently[ Go to top ]

    Hello Sahil,

    Where can i set this property.

    Thanks
  6. Help Needed urgently[ Go to top ]

    You have a better choice to do this task. You should use a detail bean into your EJB, and use only the set and get of this attribute. With this, you will avoid that each time you use a set method the container calls ejbLoad(). If your DB is used only by your application you can use a flag called isModified and when you detect you have changed the detail bean you must put the flag to true. And in the ejbStore() method you can decide if you want to do the storing operation or not.

    Maybe with this you will be able to perform better your task.
  7. Help Needed urgently[ Go to top ]

    Sachin,
    getting a load/store on every entity method call means that the methods are executing in their own transaction. Declare container managed transactions something like this:

    <assembly-descriptor>
      <container-transaction>
        <method>
          <ejb-name>MySessionBean</ejb-name>
          <method-name>*</method-name>
        </method>
        <trans-attribute>Required</trans-attribute>
      </container-transaction>
      <container-transaction>
        <method>
          <ejb-name>MyEntityBean</ejb-name>
          <method-name>*</method-name>
        </method>
        <trans-attribute>Required</trans-attribute>
      </container-transaction>
    </assembly-descriptor>

    This means the container will start a transaction when the session bean method is called. The 70 or so entity set methods will all shar the same transaction, you should see a single load/store.