klyn.data.EntityManager.beginTransaction
method
public beginTransaction() as EntityTransaction:
Description

Begins the transaction bound to this manager's provider session.

A manager owns one transaction coordinator. Calling this method while that transaction is active raises an exception rather than creating a second transaction over the same provider session.

Returns

Active transaction used to commit or roll back provider work.

Throws
  • EntityManagerClosedException when this manager is closed.
  • TransactionException when a transaction is already active or the provider cannot start one.
  • ProviderCapabilityException when the provider has no transaction support.
Example
transaction = manager.beginTransaction()
try:
manager.persist(user)
transaction.commit()
catch error as Exception:
if transaction.active:
transaction.rollback()
throw error