Transaction Management in JavaEE-transaction Overview (1), javaee transactions
Today, I want to talk about transaction management. Readers may or may not understand it. It is actually very simple (Please bypass it yourself ). I wanted to reference an idiom to describe the characteristics of transactions, but I did not find it suitable, so I found the following groups of idioms to describe transactions. In fact, the description of the transaction in the official document is also divided into four aspects. Here, I will explain it with my own understanding.
The first pair of words is: "Open the bow without looking back" and "Do your best? Success or failure ?)
The combination of these words seems to be the atomicity of transactions, that is, what we usually say is done, or nothing else. The previous steps show that the transaction has been successful. The subsequent steps are to roll back the transaction when the execution fails, that is, the transaction remains unchanged (refer to the following features-consistency ).
The second pair of words are: "Keep your mouth secure" and "look like a watch"
The combination of these terms is transaction consistency, which means that after a transaction ends, data will be valid and cannot be understood. In other words, this feature is a supplement to the previous feature. If you don't want to do it in half, I'm sorry you have to restore it to its original state. You can't change part of the data, and the other part has not changed.
The third pair of words is: "Nothing is too high to be suspended" and "sweep the snow in front of your own door, do not care about others on the cream"
The translation of these words into a white text is "taking care of me", which represents another feature of transactions-isolation. That is to say, there is no relationship between different transactions. After the transaction is committed, other transactions can see changes. Otherwise, external transactions are like a black box and do not know what they are doing.
The fourth pair of words is: "Dust settled" and "rice cooked mature rice"
This word means that everything has been done. Don't regret it. The features mapped to transactions are persistent. Once the transaction is completed, the changes made in the transaction will continue to be maintained. Of course, another transaction will be changed.
In the official documents, transactions that meet the preceding four features are called ACID transactions (A: atomicity, C: consistency, I: isolation, D: durability ). However, when meeting the ACID attribute, people will adopt flexible policies considering performance issues. For example, for the isolation level of data, people can set more relaxed or stricter regulations than before. (For details, refer to the Wikipedia entry "transaction isolation .) The rule is to improve performance or to obtain more consistent data.