• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Entity Bean - BMP - Transaction

Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whether to perform commit/rollback programatically for persistance code in a Bean Managed Persistance for an Entity Bean?
  • Entity Bean - BMP: We need to provide logic for persistance to a Database.
  • Entity Bean - HAS to have Container Managed Transaction (atleast for the Remote Business Methods).

  • Following is a pseudo code. What should be done at the question marks?
    Ranch Hand
    Posts: 1683
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    If you use JDBC transactions in your BMP bean, then the usual rules apply. So, you would disable auto-commit is if makes sense and then explicitly commit after the insert. And don't forget to close the Connection.

    However, do not get physical connections - I don't like doing this at all. It is best to get logical connections by obtaining your connections from the pool via the DataSource.

    You must declare transaction attributes for the create, remove and business methods declared in the bean's interfaces. The container will run the methods in the appropriate transactions. Here is a summary.
    The ejbCreate and ejbRemove methods run in the transaction context of the matching create and remove methods.

    The ejbLoad method will run in the transaction context determined by the transaction attribute of the business method that triggered the ejbLoad method.

    The ejbStore method will run in the same transaction context as the previously invoked ejbLoad or ejbCreate method.
    So, if the create method has a trans attribute of Required, then ejbCreate will run in a transaction.

    On another subject: never declare RemoteException in a method in the bean class as it is a violation of the spec.
    Don't get me started about those stupid light bulbs.
      Bookmark Topic Watch Topic
    • New Topic