EJB design: EjbLoad/EjbStore

  1. EjbLoad/EjbStore (7 messages)

    According to the Enterprise Javabeans Specs version 1.1 Final release, page 109:

    public void ejbLoad();
    "The container must invoke this method in the transaction context determined by the transaction attribute of the business method that triggered the ejbLoad method."

    public void ejbStore();
    "This synchronization always happens at the end of a transaction."

    Let's say I have an Employee EJB. Calling a business method like 'getEmployeeInfo()' will cause the following event to happen:

    1) App server call ejbLoad() when getEmployeeInfo() is called
    2) App server calls the actual getEmployeeInfo()
    3) App server finally calls ejbStore()

    Let's say I have another method called 'updateEmployeeInfo(Employee emp). The following will happen:

    1) App server calls ejbLoad() when updateEmployeeInfo() is called
    2) App server calls the actual updateEmployeeInfo(Employee emp)
    3) App server finally calls ejbStore()

    Is this what is really happening? I can see some operation as being redundant.

    Benedict Chng

    Threaded Messages (7)

  2. EjbLoad/EjbStore[ Go to top ]


    Yes, it is. But some Application Servers provide custom optimization. So either ejbLoad or ejbStore will not be called so often. Of course it is proprietary solution and it is not covered by EJB spec.

    Best regards,

  3. EjbLoad/EjbStore[ Go to top ]


    A few things

    1) You may find some of these calls to be redundant but the container HAS to assure persistance and depending on the tx boundries you may see unexpected calls to ejbStore(). For instance to prevent scenarios like a Local Diamond the container may need to call ejbLoad() even outside a tx boundry. Or, lets say another instance of the entity did an ejbStore() forcing the container to do an ejbLoad() to read the same data again.

    2) Some containers like Sybase EAServer have optimizations to this. For instance, in EAServer you can mark a property as read-only so it doesnt need to call ejbStore().

    Dave Wolf
    Internet Applications Division
  4. EjbLoad/EjbStore[ Go to top ]

    if u are using WebLogic, u can use isModified() to eliminate redundant write operation to the database for the read-only operation.

  5. EjbLoad/EjbStore[ Go to top ]

    Note that isModified is a proprietary API and not portable across containers. Thats why in EAServer we made the option declarative so you never had to write proprietary code.

    Dave Wolf
    Internet Applications Division
  6. EjbLoad/EjbStore[ Go to top ]

    The option is also declarative in WLS. The declaration provides the option to specify a method that returns a boolean to denote whether there is a requirement to call ejbStore at all.

    All in all weblogic provides very good scope for efficient use of data store persistence.

    I have written a detailed design document regarding ejbLoad and ejbStore with WebLogic 5.1 which I intend to post to this group. It would be interesting to get some feedback first, especially from the perspective of other application servers.

    Anyone interested in taking a look?

    Aaron Robinson
    AaronRobinson67 at yahoo dot co.uk
  7. EjbLoad/EjbStore[ Go to top ]

    I would be very interested in this since I originally posted this message.
  8. EjbLoad/EjbStore[ Go to top ]

    Can you point me to a link on weblogic site where the documentation for this is found?

    Benedict Chng