Discussions

EJB programming & troubleshooting: Avoiding ejbLoad/ejbStore for get methods in websphere

  1. We are using *BMPs* for our Entity beans.The application server is the latest Websphere that supports "ejb 1.1".

    Here is the problem:
    Everytime I access a get method on the bean, it looks like both ejbLoad/ejbStore are getting called. There is no need to do this and it obviously is a lot of overhead.

    We tried setting the transaction attributes of the get methods to Not Supported. We also set the session bean method's(that actually calls the get) transaction attributes to be not supported. But it still doesn't work.

    At last, we implemented a 'dirty flag' pattern to avoid the ejbStores.But we still have the ejbLoad problem.

    I am sure some of you must have faced the same problem.I would really appreciate it if you could please advice me on this.
    As a reminder this is regarding "BMP with ejb 1.1" and "Websphere".
    Thanks in advance,
    saji

  2. Dont call the entity directly, use a SB as a facade.

    Containers are required to maintain persistance of entity beans. If no tx is pending when the entity bean is called, the container has no choice but to persist at every method call. It doesnt know setters from getters and even if it did, diamonds would prolly force it to do so anyways.

    Soooo, the way to assure that every method call doesnt do a load/store is to make sure a tx is always pending. One way to do this is to set TX_MANDATORY on the entity bean. That way if anyone tries to call the entity bean without a tx started, the entity will throw an exception.

    You might check out my presentation on transactions from JavaOne the year before last.

    Dave Wolf
    dave at getpersonified dot com
  3. Hi Dave,
     Thanks for the reply.
    Yes, I am using a session facade to access my entity bean.
    None of my business methods(atleast until now) needs to run under a transaction.
    When you say set TX_MANDATORY on the entity bean, what should be the transaction settings on the session bean method?

    Also could you tell me the name of your presentation?

    Arun, thanks for the reply..but I don't think the lazy loading pattern could avoid the ejbload/ejbstore.It could only delay the loading of certain atributes, especially where you have dependent objects. Unfortunately I need all the atrtributes of the entity bean , every time.And I don't want to write sql statements for each attrubutes, if you know what I mean. Dave, any comments one this?
  4. The Facades should have TX_REQUIRED set. If you do not, there is no pending TX running when the entity is called. Setting TX_MANDATORY will make sure you just dont forget to do this. Your business logic may not need a TX, but the TX will prevent all the useless persists.

    The presentation was titled "Advaced Transaction Processing III"

    Dave Wolf
    dave at getpersonified dot com
  5. Hi Aravind ,

      You are trying good..ejbStore() and ejbload() are bean
      call back methods. Ya we can control these methods using
      isdirtyFlag I am very much sure if you implemented this
      in right manner it should work.But if still give u
      problem use lazy loading design patteren. Where u no need
      to implement ejbStore and ejbLoad().


    Bye

    Arun Sethia

    sethia_jain@yahoo.com