EJB design: Do I have to make all getXX and setXX in tx to skip callbacks ?

  1. Hi all,
    I have a design question. If I enlist all Entity Beans gets and sets withing the same tx there won't be ejbLoad and ejbStore callbacks. So is it a good choice to demarcate -always- all gets and sets within the same transaction?
    Anyway, I don't understand why ejbStore isn't called if I do setXXX within the same transaction. Is it an optimization of some containers (WLS) ?
  2. I'm not sure what the exact issue you are facing is. Assuming you are using a session bean facade, it should enforce transactional control (new, use existing, etc.) over the use case in question. Your Entity Beans would then be deployed using "Transaction Required". This way the first time an EB "joins" the transaction it's ejbLoad() will be called. Now while you are within the transaction, any getXXX() and setXXX() call do not need to persist information in the DB. Your changes are visible to all other components in the same transaction. When the transaction commits, ejbStore() will be called on your EBs.

    Of course when you have multiple EBs, the order in which ejbStore() is called on each EB is not defined. This can cause it's own set of problems, but I digress.