
com.avaje.ebeaninternal.server.transaction.JdbcTransaction Maven / Gradle / Ivy
package com.avaje.ebeaninternal.server.transaction;
import com.avaje.ebean.TransactionCallback;
import com.avaje.ebean.bean.PersistenceContext;
import com.avaje.ebean.config.PersistBatch;
import com.avaje.ebean.config.dbplatform.DatabasePlatform.OnQueryOnly;
import com.avaje.ebean.event.changelog.BeanChange;
import com.avaje.ebean.event.changelog.ChangeSet;
import com.avaje.ebeaninternal.api.DerivedRelationshipData;
import com.avaje.ebeaninternal.api.SpiTransaction;
import com.avaje.ebeaninternal.api.TransactionEvent;
import com.avaje.ebeaninternal.server.core.PersistRequest;
import com.avaje.ebeaninternal.server.core.PersistRequestBean;
import com.avaje.ebeaninternal.server.lib.util.Str;
import com.avaje.ebeaninternal.server.persist.BatchControl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.persistence.PersistenceException;
import javax.persistence.RollbackException;
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
/**
* JDBC Connection based transaction.
*/
public class JdbcTransaction implements SpiTransaction {
private static final Logger logger = LoggerFactory.getLogger(JdbcTransaction.class);
private static final Object PLACEHOLDER = new Object();
private static final String illegalStateMessage = "Transaction is Inactive";
/**
* The associated TransactionManager.
*/
protected final TransactionManager manager;
/**
* The transaction id.
*/
protected final String id;
/**
* Flag to indicate if this was an explicitly created Transaction.
*/
protected final boolean explicit;
/**
* Behaviour for ending query only transactions.
*/
protected final OnQueryOnly onQueryOnly;
/**
* The status of the transaction.
*/
protected boolean active;
/**
* The underlying Connection.
*/
protected Connection connection;
/**
* Used to queue up persist requests for batch execution.
*/
protected BatchControl batchControl;
/**
* The event which holds persisted beans.
*/
protected TransactionEvent event;
/**
* Holder of the objects fetched to ensure unique objects are used.
*/
protected PersistenceContext persistenceContext;
/**
* Used to give developers more control over the insert update and delete
* functionality.
*/
protected boolean persistCascade = true;
/**
* Flag used for performance to skip commit or rollback of query only
* transactions in read committed transaction isolation.
*/
protected boolean queryOnly = true;
protected boolean localReadOnly;
protected Boolean updateAllLoadedProperties;
protected PersistBatch oldBatchMode;
protected PersistBatch batchMode;
protected PersistBatch batchOnCascadeMode;
protected int batchSize = -1;
protected boolean batchFlushOnQuery = true;
protected Boolean batchGetGeneratedKeys;
protected Boolean batchFlushOnMixed;
protected String logPrefix;
/**
* The depth used by batch processing to help the ordering of statements.
*/
protected int depth;
/**
* Set to true if the connection has autoCommit=true initially.
*/
protected boolean autoCommit;
protected IdentityHashMap
© 2015 - 2025 Weber Informatics LLC | Privacy Policy