|
| 1 | +package data_transaction_jpa.question_14_15_16_17_18_19; |
| 2 | +import org.springframework.context.annotation.Bean; |
| 3 | +import org.springframework.context.annotation.Configuration; |
| 4 | +import org.springframework.transaction.annotation.Propagation; |
| 5 | +import org.springframework.transaction.annotation.Transactional; |
| 6 | + |
| 7 | +/** |
| 8 | + * |
| 9 | + * 1-What does transaction propagation mean? |
| 10 | + * Behaviour of a transaction in relation to another transaction, there are 7 propagation types: |
| 11 | + * T1 |
| 12 | + * a(){ |
| 13 | + * T2 |
| 14 | + * b(); |
| 15 | + * } |
| 16 | + * {@link Propagation#REQUIRED} //default in Spring |
| 17 | + * T2 will use T1 if T1 exists, will create a new Transaction otherwise. |
| 18 | + * {@link Propagation#REQUIRES_NEW} |
| 19 | + * every time, T2 will crete a new transaction. |
| 20 | + * {@link Propagation#NESTED} |
| 21 | + * T2 will use T1 if T1 exists, will create a new Transaction otherwise. If T2 rollback, T1 will rollback to. |
| 22 | + * {@link Propagation#SUPPORTS} |
| 23 | + * use T1 if it exists, do nothing otherwise |
| 24 | + * {@link Propagation#NOT_SUPPORTED} |
| 25 | + * suspend T1 if it exists, do nothing otherwise |
| 26 | + * {@link Propagation#NEVER} |
| 27 | + * throw an exception if T1 exist, do nothing otherwise |
| 28 | + * {@link Propagation#MANDATORY} |
| 29 | + * throw an exception if T1 doesn't exist, use T1 otherwise |
| 30 | + * |
| 31 | + * 2-What happens if one @Transactional annotated method is calling another @Transactional annotated method on the same object instance? |
| 32 | + * the inner method will not run on a transactional mode. |
| 33 | + * 3-Where can the @Transactional annotation be used? What is a typical usage if you put in class level? |
| 34 | + * 4-What does declarative transaction management mean? |
| 35 | + * Class, method level. method override class level. All method in a annotated class level will be automatically annotated. |
| 36 | + * 5-What is the default rollback policy? How can you override it? |
| 37 | + * rollback whenever an unchecked exception (RuntimeException or Error)is thrown from a method. |
| 38 | + * thrown in this scenario means that it was not cached by a try block catch in the method. |
| 39 | + * 6- rollback policy overridden by : |
| 40 | + * rollBackFor |
| 41 | + * rollBackForClassName |
| 42 | + * noRollBackFor |
| 43 | + * noRollBackForClassName |
| 44 | + * |
| 45 | + * |
| 46 | + */ |
| 47 | +public class TransactionPropagation { |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | +} |
0 commit comments