All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.ebeaninternal.server.transaction.ExternalJdbcTransaction Maven / Gradle / Ivy

There is a newer version: 15.8.0
Show newest version
package io.ebeaninternal.server.transaction;

import javax.persistence.PersistenceException;
import java.sql.Connection;

/**
 * Transaction based on a java.sql.Connection supplied by an external
 * transaction manager such as Spring.
 * 

* 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. *

*

* That is, a transaction started externally (by Spring etc) must be committed * or rolled back externally as well. *

*/ public class ExternalJdbcTransaction extends JdbcTransaction { /** * Create a Transaction that will have no transaction logging support. *

* You need to create with a TransactionManager to have transaction logging. *

*/ public ExternalJdbcTransaction(Connection connection) { super(true, connection, null); } /** * Construct will all explicit parameters. */ public ExternalJdbcTransaction(boolean explicit, Connection connection, TransactionManager manager) { super(explicit, connection, manager); } /** * This will always throw a PersistenceException. *

* Externally created connections should be committed or rolled back externally. *

*/ @Override public void commit() { throw new PersistenceException("This is an external transaction so must be committed externally"); } /** * This will always throw a PersistenceException. *

* Externally created connections should be committed or rolled back externally. *

*/ @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. *

* Externally created connections should be committed or rolled back externally. *

*/ @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. *

* Externally created connections should be committed or rolled back externally. *

*/ @Override public void rollback(Throwable e) throws PersistenceException { throw new PersistenceException("This is an external transaction so must be rolled back externally", e); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy