Skip to main content

Transactions

Transactions in NS Applications are implemented by the Logic layer. They are provided by the EJB container on every method call by the Proxy layer.

When a method on the bean is called by another class, the transaction attribute decides what the transaction behaviour will be. This transaction attribute is declared with an annotation:

@TransactionAttribute(REQUIRES_NEW)
public void someMethod() { }

It can have one of the following values:

  • Required (default): Starts a transaction if none is defined, or, if the method is called as part of a bigger transaction, it will join this transaction.
  • RequiresNew: Starts a new transaction. If the method is called as part of a bigger transaction, that transaction will be suspended until this method has finished.
  • Mandatory: Requires an encompassing transaction. Fails if it is called without a transaction.
  • NotSupported: Does not support a transaction. If called as part of a bigger transaction, that transaction will be suspended while this method is being executed.
  • Supports: Can run as part of a transaction, but it does not start a transaction by itself.
  • Never: Does not support a transaction. Fails if called as part of a bigger transaction.

Transactions for Agents

When calling a method on a DataElement agent, the transaction starts when the proxy calls the method on the bean. That same transaction is committed when the bean returns a result.