August 2018
Intermediate to advanced
314 pages
8h 9m
English
The Transaction class is responsible for controlling the transaction lifecycle and defining the transaction delimit:
package com.packt.javaee8.domainstore;import javax.annotation.PostConstruct;public class Transaction { private boolean opened; @PostConstruct public void init(){ this.opened = false; } public void commit() throws Exception { if( !opened ) throw new Exception("Transaction is not opened"); opened = false; } public void rollback() throws Exception { if( !opened ) throw new Exception("Transaction is not opened"); opened = false; } public void begin() throws Exception { if( opened ) throw new Exception("Transaction already is opened"); opened = true; } public boolean isOpened(){ return opened
Read now
Unlock full access