Details

    • Type: Sub-task Sub-task
    • Status: Closed
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.2.0
    • Component/s: jdbc, kernel
    • Labels:
      None

      Description

      OpenJPA occasionally needs to perform work in a non-business transaction (see AbstractJDBCSeq.java). In a transactional environment, one way that this is achieved is by suspending the current JTA transaction, starting a new one, doing the work, cleaning up the new tx, and resuming the original one. Some environments do not allow direct transaction control, but mechanisms such as stateless session beans can often be used to kick off atomic operations that should execute in a separate transaction.

      We could easily add ManagedRuntime.executeInNewTransaction(Runnable) that captured this slightly-coarser-grained transaction control. The default implementation could simply do suspend(), begin(), invoke Runnable.run(), commit()/rollback(), resume().

        Issue Links

          Activity

          Hide
          Michael Dick added a comment -

          Under svn revision 651441 I added a doNonTransactionalWork method to the ManagedRuntime interface. Here's the relevant signature :

          /**

          • <P>
          • Do a unit of work which will execute outside of the current managed
          • transaction.
          • </P>
          • <P>
          • If the runnable object encounters an exception it should be wrapped in a
          • RuntimeException and thrown back to the caller
          • </P>
          • @param runnable
          • The runnable wrapper for the work that will be done. The
          • runnable object should be fully initialized with any state
          • needed to execute.
          • @throws NotSupportedException
          • if the transaction can not be suspended.
            */
            public void doNonTransactionalWork(Runnable runnable)
            throws NotSupportedException;

          Currently the interface is only used when we obtain a sequence value from a sequence table (see TableJDBCSeq.java). The default implementation, found in AbstractManagedRuntime will merely suspend, execute, then resume the current transaction.

          Subclasses can further refine this behavior and to take advantage of vendor specific hooks. An example has been provided for WebSphere Application Server under OPENJPA-159.

          Show
          Michael Dick added a comment - Under svn revision 651441 I added a doNonTransactionalWork method to the ManagedRuntime interface. Here's the relevant signature : /** <P> Do a unit of work which will execute outside of the current managed transaction. </P> <P> If the runnable object encounters an exception it should be wrapped in a RuntimeException and thrown back to the caller </P> @param runnable The runnable wrapper for the work that will be done. The runnable object should be fully initialized with any state needed to execute. @throws NotSupportedException if the transaction can not be suspended. */ public void doNonTransactionalWork(Runnable runnable) throws NotSupportedException; Currently the interface is only used when we obtain a sequence value from a sequence table (see TableJDBCSeq.java). The default implementation, found in AbstractManagedRuntime will merely suspend, execute, then resume the current transaction. Subclasses can further refine this behavior and to take advantage of vendor specific hooks. An example has been provided for WebSphere Application Server under OPENJPA-159 .
          Hide
          Michael Dick added a comment -

          Edit,messed up the link, the new WebSphere Managed runtime is provided in OPENJPA-149

          Show
          Michael Dick added a comment - Edit,messed up the link, the new WebSphere Managed runtime is provided in OPENJPA-149

            People

            • Assignee:
              Michael Dick
              Reporter:
              Patrick Linskey
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development