001/** 002 * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). 003 * <p> 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * <p> 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * <p> 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package com.mybatisflex.core.transaction; 017 018/** 019 * 事务的传递方式,参考 spring 020 */ 021public enum Propagation { 022 023 //若存在当前事务,则加入当前事务,若不存在当前事务,则创建新的事务 024 REQUIRED(0), 025 026 //若存在当前事务,则加入当前事务,若不存在当前事务,则已非事务的方式运行 027 SUPPORTS(1), 028 029 //若存在当前事务,则加入当前事务,若不存在当前事务,则抛出异常 030 MANDATORY(2), 031 032 //始终以新事物的方式运行,若存在当前事务,则暂停(挂起)当前事务。 033 REQUIRES_NEW(3), 034 035 //以非事物的方式运行,若存在当前事务,则暂停(挂起)当前事务。 036 NOT_SUPPORTED(4), 037 038 //以非事物的方式运行,若存在当前事务,则抛出异常。 039 NEVER(5), 040 041 //如果存在当前事务,则在嵌套事务中执行,否则行为类似于 PROPAGATION_REQUIRED 042 NESTED(6), 043 ; 044 045 private int value; 046 047 Propagation(int value) { 048 this.value = value; 049 } 050 051 public int getValue() { 052 return value; 053 } 054 055 public void setValue(int value) { 056 this.value = value; 057 } 058}