mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#919 - io.ebean package initial
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
package io.ebeaninternal.server.transaction;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
import javax.persistence.RollbackException;
|
||||
import java.sql.Connection;
|
||||
|
||||
/**
|
||||
* Transaction based on a java.sql.Connection supplied by an external
|
||||
* transaction manager such as Spring.
|
||||
* <p>
|
||||
* This means that the transaction demarcation [commit(), rollback(), end()]
|
||||
* must be controlled externally (by Spring etc) and so these methods [commit(),
|
||||
* rollback(), end()] can not be called on this ExternalJdbcTransaction.
|
||||
* </p>
|
||||
* <p>
|
||||
* That is, a transaction started externally (by Spring etc) must be committed
|
||||
* or rolled back externally as well.
|
||||
* </p>
|
||||
*/
|
||||
public class ExternalJdbcTransaction extends JdbcTransaction {
|
||||
|
||||
/**
|
||||
* Create a Transaction that will have no transaction logging support.
|
||||
* <p>
|
||||
* You need to create with a TransactionManager to have transaction logging.
|
||||
* </p>
|
||||
*/
|
||||
public ExternalJdbcTransaction(Connection connection) {
|
||||
super(null, true, connection, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct will all explicit parameters.
|
||||
*/
|
||||
public ExternalJdbcTransaction(String id, boolean explicit, Connection connection, TransactionManager manager) {
|
||||
super(id, explicit, connection, manager);
|
||||
}
|
||||
|
||||
/**
|
||||
* This will always throw a PersistenceException.
|
||||
* <p>
|
||||
* Externally created connections should be committed or rolled back externally.
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public void commit() throws RollbackException {
|
||||
throw new PersistenceException("This is an external transaction so must be committed externally");
|
||||
}
|
||||
|
||||
/**
|
||||
* This will always throw a PersistenceException.
|
||||
* <p>
|
||||
* Externally created connections should be committed or rolled back externally.
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public void end() throws PersistenceException {
|
||||
throw new PersistenceException("This is an external transaction so must be committed externally");
|
||||
}
|
||||
|
||||
/**
|
||||
* This will always throw a PersistenceException.
|
||||
* <p>
|
||||
* Externally created connections should be committed or rolled back externally.
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public void rollback() throws PersistenceException {
|
||||
throw new PersistenceException("This is an external transaction so must be rolled back externally");
|
||||
}
|
||||
|
||||
/**
|
||||
* This will always throw a PersistenceException.
|
||||
* <p>
|
||||
* Externally created connections should be committed or rolled back externally.
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public void rollback(Throwable e) throws PersistenceException {
|
||||
throw new PersistenceException("This is an external transaction so must be rolled back externally");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user