SpringBoot integration of transaction processing mybatis

Isolation level
        Serializable: the most stringent, serial processing, consumption of resources in the
        Repeatable Read: to ensure that a transaction will not be read by another transaction has been modified but not committed (rollback) Data
        Read Committed: the default transaction most popular databases level
        read Uncommitted: ensure that the reading process is not illegal to read the data.

 

Common modes of transmission behavior
        PROPAGATION_REQUIRED-- support the current transaction, if no transaction creates a new transaction, the most common choice.

        PROPAGATION_SUPPORTS-- support the current transaction, if no transaction is executed in a non-transactional way.

        PROPAGATION_MANDATORY-- support the current transaction, if no transaction, throw an exception.

        PROPAGATION_REQUIRES_NEW-- New Transaction, if the current transaction exists, the current transaction is pending, there is no relationship between the two transactions, an exception, a submission will not be rolled back at the same time

        PROPAGATION_NOT_SUPPORTED-- perform operations to a non-transactional way, if the current transaction exists, put the current transaction pending.

        PROPAGATION_NEVER-- to perform non-transactional way, if the current transaction exists, an exception is thrown

 

Mention what we think of rollback.

For example, a method in which a plurality of operation linked to the operation of which will be rolled back on this transaction will use the service logic into @Transantional

@Service
@Transactional(propagation = Propagation.REQUIRED)
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public User getId(String id) {
        return userMapper.getId(id);
    }
}
Published 10 original articles · won praise 0 · Views 511

Guess you like

Origin blog.csdn.net/DNCCCC/article/details/105032783