2 Replies Latest reply on Feb 14, 2007 11:53 AM by dtseiler

    Transaction issue with separate JBoss jars

    dtseiler

      Recently we have tried to separate our EJB Project out into two parts.
      One project to handle all of our persistence and another to handle all
      of our service's. The persistence project was set up to serve out
      entity objects back through a DAO service. This way our Service project
      can just call into our DAO services and retrieve the information that
      they would need and allowing for a nice split between two different
      types of projects. However, in the process of separating these projects
      out we hit some issues with the transaction manager not flushing upon
      the call of the flush command.

      The flush command is something we greatly rely on as a means to make
      sure our data is persisted underneath the proper user in the database
      through contexts. It is also the means in which we can allow support of
      oracle proxy connections. We achieved this by having a
      PrepareDatabaseConnection AOP method; which is executed before and after
      a method is called. Allowing for us to set the database context after
      the transaction is started and to close the database context before the
      transaction ends. Ideally we would have liked to hook it directly onto
      the begging and end of the transaction but we couldn't find a great way
      to do so. So instead on every one of our services and DAO work we added
      the PrepareDatabaseConnection interceptor to properly set our database
      context or to configure the connection as a proxy connection. In a
      single jar this functionality works great. However, in separate jars we
      start to see issues with the database context not being properly set,
      which leads to issues with auditing what users changed the data in the
      database.

      In a single jar the contents flush upon my call to the entity manager to
      commit / update the information. However, when these are separate jars
      the flush doesn't occur until the transaction manager tells it to flush
      and close the transaction. At which point in time the database context
      has already been unset leaving no record of which user was actually
      using that connection from the connection pool.

      Why is it when we move the database code out to a separate jar the
      entity managers flush doesn't actually flush the information when it was
      requested to?