Search in sources :

Example 1 with DefaultTransactionDefinition

use of io.micronaut.transaction.support.DefaultTransactionDefinition in project micronaut-test by micronaut-projects.

the class JpaNoRollbackTest method cleanup.

@AfterAll
void cleanup() {
    final TransactionStatus tx = transactionManager.getTransaction(new DefaultTransactionDefinition());
    final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    final CriteriaDelete<Book> delete = criteriaBuilder.createCriteriaDelete(Book.class);
    delete.from(Book.class);
    entityManager.createQuery(delete).executeUpdate();
    transactionManager.commit(tx);
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) DefaultTransactionDefinition(io.micronaut.transaction.support.DefaultTransactionDefinition) TransactionStatus(io.micronaut.transaction.TransactionStatus) AfterAll(org.junit.jupiter.api.AfterAll)

Example 2 with DefaultTransactionDefinition

use of io.micronaut.transaction.support.DefaultTransactionDefinition in project micronaut-sql by micronaut-projects.

the class MicronautDataTransactionHandler method begin.

@Override
public void begin(Handle handle) {
    TransactionDefinition definition = new DefaultTransactionDefinition(TransactionDefinition.Propagation.NESTED);
    TransactionStatus<Connection> status = this.transactionManager.getTransaction(definition);
    this.localTransactions.putIfAbsent(handle, new LocalStuff(status));
}
Also used : TransactionDefinition(io.micronaut.transaction.TransactionDefinition) DefaultTransactionDefinition(io.micronaut.transaction.support.DefaultTransactionDefinition) DefaultTransactionDefinition(io.micronaut.transaction.support.DefaultTransactionDefinition) Connection(java.sql.Connection)

Aggregations

DefaultTransactionDefinition (io.micronaut.transaction.support.DefaultTransactionDefinition)2 TransactionDefinition (io.micronaut.transaction.TransactionDefinition)1 TransactionStatus (io.micronaut.transaction.TransactionStatus)1 Connection (java.sql.Connection)1 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1 AfterAll (org.junit.jupiter.api.AfterAll)1