Entity beans have ejbLoad() to stay synchronized, even if the transaction rolls back.

  1. Client calls methods on the bean, that change the bean’s internal state.

    image with no caption
  2. Bean has a problem and can’t commit the transaction. But now that leaves the bean out of sync with the database. The bean’s limit state is 420, but the limit in the database is 343, exactly where it was before the transaction began.

    image with no caption
  3. Container simply does a new load on the bean, to refresh it with the original data from the database.

    image with no caption
  4. Bean is happy, and now all of its persistent state matches the entity’s data in the database.

    image with no caption

Get Head First EJB now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.