org.datanucleus.jpa
Class EntityTransactionImpl

java.lang.Object
  extended by org.datanucleus.jpa.EntityTransactionImpl
All Implemented Interfaces:
javax.persistence.EntityTransaction

public class EntityTransactionImpl
extends java.lang.Object
implements javax.persistence.EntityTransaction

EntityTransaction implementation for JPA for ResourceLocal transaction. Utilises the underlying ObjectManager and its real transaction, providing a JPA layer on top.

Version:
$Revision: 1.1 $

Field Summary
protected static org.datanucleus.util.Localiser LOCALISER
          Localisation utility for output messages
 
Constructor Summary
EntityTransactionImpl(org.datanucleus.ObjectManager om)
          Constructor.
 
Method Summary
protected  void assertActive()
          Convenience method to throw an exception if the transaction is not active.
 void begin()
          Start a resource transaction.
 void commit()
          Commit the current transaction, writing any unflushed changes to the database.
 boolean getRollbackOnly()
          Determine whether the current transaction has been marked for rollback.
 boolean isActive()
          Indicate whether a transaction is in progress.
 void rollback()
          Roll back the current transaction.
 void setOption(java.lang.String option, boolean value)
          Convenience accessor for setting a transaction option.
 void setOption(java.lang.String option, int value)
          Convenience accessor for setting a transaction option.
 void setOption(java.lang.String option, java.lang.String value)
          Convenience accessor for setting a transaction option.
 void setRollbackOnly()
          Mark the current transaction so that the only possible outcome of the transaction is for the transaction to be rolled back.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCALISER

protected static final org.datanucleus.util.Localiser LOCALISER
Localisation utility for output messages

Constructor Detail

EntityTransactionImpl

public EntityTransactionImpl(org.datanucleus.ObjectManager om)
Constructor.

Parameters:
om - The ObjectManager providing the transaction.
Method Detail

isActive

public boolean isActive()
Indicate whether a transaction is in progress.

Specified by:
isActive in interface javax.persistence.EntityTransaction
Throws:
javax.persistence.PersistenceException - if an unexpected error condition is encountered.

begin

public void begin()
Start a resource transaction.

Specified by:
begin in interface javax.persistence.EntityTransaction
Throws:
java.lang.IllegalStateException - if the transaction is active

commit

public void commit()
Commit the current transaction, writing any unflushed changes to the database.

Specified by:
commit in interface javax.persistence.EntityTransaction
Throws:
java.lang.IllegalStateException - if isActive() is false.
javax.persistence.RollbackException - if the commit fails.

rollback

public void rollback()
Roll back the current transaction.

Specified by:
rollback in interface javax.persistence.EntityTransaction
Throws:
java.lang.IllegalStateException - if isActive() is false.
javax.persistence.PersistenceException - if an unexpected error condition is encountered.

getRollbackOnly

public boolean getRollbackOnly()
Determine whether the current transaction has been marked for rollback.

Specified by:
getRollbackOnly in interface javax.persistence.EntityTransaction
Throws:
java.lang.IllegalStateException - if isActive() is false.

setRollbackOnly

public void setRollbackOnly()
Mark the current transaction so that the only possible outcome of the transaction is for the transaction to be rolled back.

Specified by:
setRollbackOnly in interface javax.persistence.EntityTransaction
Throws:
java.lang.IllegalStateException - Thrown if the transaction is not active

setOption

public void setOption(java.lang.String option,
                      int value)
Convenience accessor for setting a transaction option.

Parameters:
option - option name
value - The value

setOption

public void setOption(java.lang.String option,
                      boolean value)
Convenience accessor for setting a transaction option.

Parameters:
option - option name
value - The value

setOption

public void setOption(java.lang.String option,
                      java.lang.String value)
Convenience accessor for setting a transaction option.

Parameters:
option - option name
value - The value

assertActive

protected void assertActive()
Convenience method to throw an exception if the transaction is not active.

Throws:
java.lang.IllegalStateException - Thrown if the transaction is not active.


Copyright © 2009. All Rights Reserved.