Mapa mental
Transactions
Contenido del mapa
Transactions
@Transactional
- Propagation Type
- MANDATORY
- Support a current transaction, throw an exception if none exists.
- NESTED
- Execute within a nested transaction if a current transaction exists
- NEVER
- throw an exception if a transaction exists.
- NOT_SUPPORTED
- suspend the current transaction if one exists.
- REQUIRED
- Support a current transaction, create a new one if none exists.
- REQUIRES_NEW
- Create a new transaction, and suspend the current transaction if one exists.
- SUPPORTS
- Support a current transaction, execute non-transactionally if none exists.
- MANDATORY
- Isolation Level
- DEFAULT
- READ_COMMITTED
- keeps write locks
- Locks are released as soon as the SELECT operation is performed
- range-locks are not managed
- Restricts dirty read
- READ_UNCOMMITTED
- lowest isolation level
- may see not-yet-committed changes made by other transactions.
- REPEATABLE_READ
- keeps read and write locks
- range-locks are not managed
- SERIALIZABLE
- This is the highest isolation level.
- requires read and write locks
- Also range-locks must be acquired
- Phantom reads doesnt ocurrs
- Time out
- readOnly flag
- Optimization in some cases
- when you are using Hibernate
- Provide safe guard
- Oracle and some other databases
- Optimization in some cases
- Rollback rules
- by default, rollback happens for unchecked exceptions only (Runtime)
- Spring create a proxy for this class
- To inject transactional logic before and after the method being invoked
- if the bean is implementing an interface
- any self-invocation calls will not start any transaction
- even if the method is annotated with @Transactional.
- any self-invocation calls will not start any transaction
- <tx:annotation-driven />
- Enables Transactions
- Propagation Type
Global Transactions
- work with multiple transactional resources
- Multiples Databases?
- work with multiple transactional resources
Local Transactions
- Local transactions are resource-specific
- JDBC connection
- Local transactions are resource-specific
PlatformTransactionManager (Interface)
- commit(TransactionStatus ts)
- rollback(TransactionStatus status)
- TransactionStatus getTransaction(TransactionDefinition definition)
- throw a TransactionException
- RuntimeException
TransactionTemplate
- Is a template emplates such as the JdbcTemplate
- Need a TransactionCallback implementation
- will contain code that you need to have execute in the context of a transaction
- Propagation mode, the isolation level, the timeout, can be set programmatically
- Or in configuration
- they are threadsafe
- Simplifies programmatic transaction demarcation and transaction exception handling.
- the central method is execute(TransactionalCallback)
Spring AOP is used to apply the transaction
- if an target method1, calling an method2 directly in the target object
- will not be applied by the proxy to the method2
- if an target method1, calling an method2 directly in the target object
Información
- Descripción
- Mapa Mental sobre Transactions, creado por Felipe Malfatti el 17/04/2018.
- Creado por
- Felipe Malfatti
- Visitas
- 0
- Valoración