/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package transaction type Propagation int8 type TransactionInfo struct { TimeOut int32 Name string Propagation Propagation LockRetryInternal int64 LockRetryTimes int64 } const ( /** * The REQUIRED. * The default propagation. * *
* If transaction is existing, execute with current transaction, * else execute with new transaction. *
* *
* The logic is similar to the following code:
*
*
* if (tx == null) {
* try {
* tx = beginNewTransaction(); // begin new transaction, is not existing
* Object rs = business.execute(); // execute with new transaction
* commitTransaction(tx);
* return rs;
* } catch (Exception ex) {
* rollbackTransaction(tx);
* throw ex;
* }
* } else {
* return business.execute(); // execute with current transaction
* }
*
* If transaction is existing, suspend it, and then execute business with new transaction. *
* *
* The logic is similar to the following code:
*
*
* try {
* if (tx != null) {
* suspendedResource = suspendTransaction(tx); // suspend current transaction
* }
* try {
* tx = beginNewTransaction(); // begin new transaction
* Object rs = business.execute(); // execute with new transaction
* commitTransaction(tx);
* return rs;
* } catch (Exception ex) {
* rollbackTransaction(tx);
* throw ex;
* }
* } finally {
* if (suspendedResource != null) {
* resumeTransaction(suspendedResource); // resume transaction
* }
* }
*
* If transaction is existing, suspend it, and then execute business without transaction. *
* *
* The logic is similar to the following code:
*
*
* try {
* if (tx != null) {
* suspendedResource = suspendTransaction(tx); // suspend current transaction
* }
* return business.execute(); // execute without transaction
* } finally {
* if (suspendedResource != null) {
* resumeTransaction(suspendedResource); // resume transaction
* }
* }
*
* If transaction is not existing, execute without global transaction, * else execute business with current transaction. *
* *
* The logic is similar to the following code:
*
*
* if (tx != null) {
* return business.execute(); // execute with current transaction
* } else {
* return business.execute(); // execute without transaction
* }
*
* If transaction is existing, throw exception, * else execute business without transaction. *
* *
* The logic is similar to the following code:
*
*
* if (tx != null) {
* throw new TransactionException("existing transaction");
* }
* return business.execute(); // execute without transaction
*
* If transaction is not existing, throw exception, * else execute business with current transaction. *
* *
* The logic is similar to the following code:
*
*
* if (tx == null) {
* throw new TransactionException("not existing transaction");
* }
* return business.execute(); // execute with current transaction
*