/** * Start a transaction with 'REQUIRED' semantics. * <p> * If a transaction already exists that transaction will be used. * </p> * <p> * Note that the transaction is stored in a ThreadLocal variable. * </p> */ @Override public Transaction beginTransaction() { return beginTransaction(TxScope.required()); }
/** * Helper method to create a TxScope with SUPPORTS. */ public static TxScope supports() { return new TxScope(TxType.SUPPORTS); }
private TxScope initTxScope(TxScope txScope) { if (txScope == null) { return new TxScope(); } else { // check for implied batch mode via setting batchSize txScope.checkBatchMode(); return txScope; } }
this.created = created; this.transaction = transaction; this.noRollbackFor = txScope.getNoRollbackFor(); this.rollbackFor = txScope.getRollbackFor(); if (!created && txScope.isBatchSet() || txScope.isBatchOnCascadeSet() || txScope.isBatchSizeSet()) { restoreBatch = transaction.isBatchMode(); restoreBatchOnCascade = transaction.isBatchOnCascade(); restoreBatchFlushOnQuery = transaction.isBatchFlushOnQuery(); if (txScope.isBatchSet()) { transaction.setBatchMode(txScope.isBatchMode()); if (!txScope.isFlushOnQuery()) { transaction.setBatchFlushOnQuery(false); if (txScope.isBatchOnCascadeSet()) { transaction.setBatchOnCascade(txScope.isBatchOnCascade()); if (txScope.isBatchSizeSet()) { transaction.setBatchSize(txScope.getBatchSize()); if (txScope.isSkipGeneratedKeys()) { transaction.setBatchGetGeneratedKeys(false);
private void initNewTransaction(SpiTransaction transaction, TxScope txScope) { if (txScope.isSkipCache()) { transaction.setSkipCache(true); } String label = txScope.getLabel(); if (label != null) { transaction.setLabel(label); } int profileId = txScope.getProfileId(); if (profileId > 0) { transaction.setProfileStream(profileHandler.createProfileStream(profileId)); } ProfileLocation profileLocation = txScope.getProfileLocation(); if (profileLocation != null) { profileLocation.obtain(); transaction.setProfileLocation(profileLocation); } }
@Override protected void doStartTx(Object delegate, boolean readOnly) { if (readOnly) { TxScope scope = TxScope.required().setReadOnly(true); ebeanReadOnly.beginTransaction(scope); } else { ebean.beginTransaction(); } }
TxType type = txScope.getType(); break; default: transaction = createTransaction(true, txScope.getIsolationLevel()); initNewTransaction(transaction, txScope);
this.created = created; this.transaction = transaction; this.noRollbackFor = txScope.getNoRollbackFor(); this.rollbackFor = txScope.getRollbackFor(); if (!created && txScope.isBatchSet() || txScope.isBatchOnCascadeSet() || txScope.isBatchSizeSet()) { restoreBatch = transaction.isBatchMode(); restoreBatchOnCascade = transaction.isBatchOnCascade(); restoreBatchFlushOnQuery = transaction.isBatchFlushOnQuery(); if (txScope.isBatchSet()) { transaction.setBatchMode(txScope.isBatchMode()); if (!txScope.isFlushOnQuery()) { transaction.setBatchFlushOnQuery(false); if (txScope.isBatchOnCascadeSet()) { transaction.setBatchOnCascade(txScope.isBatchOnCascade()); if (txScope.isBatchSizeSet()) { transaction.setBatchSize(txScope.getBatchSize()); if (txScope.isSkipGeneratedKeys()) { transaction.setBatchGetGeneratedKeys(false);
private void initNewTransaction(SpiTransaction transaction, TxScope txScope) { if (txScope.isSkipCache()) { transaction.setSkipCache(true); } String label = txScope.getLabel(); if (label != null) { transaction.setLabel(label); } int profileId = txScope.getProfileId(); if (profileId > 0) { transaction.setProfileStream(profileHandler.createProfileStream(profileId)); } ProfileLocation profileLocation = txScope.getProfileLocation(); if (profileLocation != null) { profileLocation.obtain(); transaction.setProfileLocation(profileLocation); } }
TxType type = txScope.getType(); break; default: transaction = createTransaction(true, txScope.getIsolationLevel()); initNewTransaction(transaction, txScope);
/** * <p>switchToRequiredScope.</p> */ public void switchToRequiredScope() { txScope = TxScope.required(); }
/** * Helper method to create a TxScope with NEVER. */ public static TxScope never() { return new TxScope(TxType.NEVER); }
private TxScope initTxScope(TxScope txScope) { if (txScope == null) { return new TxScope(); } else { // check for implied batch mode via setting batchSize txScope.checkBatchMode(); return txScope; } }
/** * Start a transaction with 'REQUIRED' semantics. * <p> * If a transaction already exists that transaction will be used. * </p> * <p> * Note that the transaction is stored in a ThreadLocal variable. * </p> */ @Override public Transaction beginTransaction() { return beginTransaction(TxScope.required()); }
/** * Helper method to create a TxScope with REQUIRES_NEW. */ public static TxScope requiresNew() { return new TxScope(TxType.REQUIRES_NEW); }
/** * Helper method to create a TxScope with REQUIRES. */ public static TxScope required() { return new TxScope(TxType.REQUIRED); }
/** * Helper method to create a TxScope with NOT_SUPPORTED. */ public static TxScope notSupported() { return new TxScope(TxType.NOT_SUPPORTED); }
/** * Helper method to create a TxScope with MANDATORY. */ public static TxScope mandatory() { return new TxScope(TxType.MANDATORY); }
/** * Helper method to create a TxScope with REQUIRES. */ public static TxScope required() { return new TxScope(TxType.REQUIRED); }
/** * Helper method to create a TxScope with REQUIRES_NEW. */ public static TxScope requiresNew() { return new TxScope(TxType.REQUIRES_NEW); }