CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-javax--javaee-api

Complete Java Enterprise Edition 8 specification APIs providing all standardized enterprise application development interfaces

Pending
Overview
Eval results
Files

transactions.mddocs/

Transaction Management

JTA API for declarative and programmatic transaction management with XA resource coordination.

Core Interfaces

public interface UserTransaction {
    void begin() throws NotSupportedException, SystemException;
    void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException;
    void rollback() throws IllegalStateException, SecurityException, SystemException;
    void setRollbackOnly() throws IllegalStateException, SystemException;
    int getStatus() throws SystemException;
    void setTransactionTimeout(int seconds) throws SystemException;
}

public interface TransactionManager extends UserTransaction {
    Transaction getTransaction() throws SystemException;
    void setTransactionTimeout(int seconds) throws SystemException;
    Transaction suspend() throws SystemException;
    void resume(Transaction tobj) throws InvalidTransactionException, IllegalStateException, SystemException;
}

public interface Transaction {
    void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, SystemException;
    void rollback() throws IllegalStateException, SystemException;
    void setRollbackOnly() throws IllegalStateException, SystemException;
    int getStatus() throws SystemException;
    boolean enlistResource(XAResource xaRes) throws RollbackException, IllegalStateException, SystemException;
    boolean delistResource(XAResource xaRes, int flag) throws IllegalStateException, SystemException;
    void registerSynchronization(Synchronization sync) throws RollbackException, IllegalStateException, SystemException;
}

Transaction Annotations

@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface Transactional {
    TxType value() default TxType.REQUIRED;
    Class[] rollbackOn() default {};
    Class[] dontRollbackOn() default {};
}

Usage Example

@Stateless
public class OrderService {
    
    @Resource
    private UserTransaction userTransaction;
    
    @Transactional
    public void processOrder(Order order) {
        // Automatically wrapped in transaction
        orderRepository.save(order);
        inventoryService.updateStock(order.getItems());
    }
    
    public void manualTransaction() throws Exception {
        userTransaction.begin();
        try {
            // Business logic
            userTransaction.commit();
        } catch (Exception e) {
            userTransaction.rollback();
            throw e;
        }
    }
}

Install with Tessl CLI

npx tessl i tessl/maven-javax--javaee-api

docs

dependency-injection.md

ejb.md

enterprise-services.md

index.md

json-processing.md

messaging.md

persistence.md

rest-services.md

security.md

transactions.md

validation.md

web-services.md

web-technologies.md

xml-binding.md

tile.json