Understanding of level 1 cache and snapshot zone in Hibernate, level 1 cache in hibernate
At the beginning, I felt that this snapshot zone was hard to understand. After reading many blogs online, I began to understand it. I understand it in combination with ADO. NET. There is a class in ADO. NET,
The name is SqlCommandBuilder. In my opinion, it is ADO.. NET and what corresponds to the Hibernate snapshot area. This SqlCommandBuilder can construct SQL statements. After the Update method is called, information in the database can be updated (including updated and deleted ), an enumeration class is also essential. It is the row state bit RowState class. I compare the row state bit with Hibernate (compare the cache and snapshot) as the corresponding class. However, when the cache area is refreshed, Hibernate compares the content in the cache area with that in the snapshot area (if different, it updates the snapshot area and stores an updata SQL statement, if a transaction is committed instead of a refresh operation, not only the updata statement is stored, but also the SQL statement of the updata is sent to the database for execution. NET does not compare, but records (that is, changes the RowStae value of the row). Finally, SqlCommandBuilder updates the row to the database based on the Status bit and primary key. In fact, in some ways, comparison is also a record (similar to modifying the row status bit), which is updated to the database until the transaction is committed.
In addition, I understand snapshot as a database snapshot (which is a snapshot of some rows of the database, and then an operation, then it is no longer a database snapshot, but after the transaction is committed, it becomes a snapshot of some rows in the database .)
For more information about SqlCommandBuilder, see this blog [SQLCommandBuilder class]
Also, this class [RowSate class]
Maybe I am not clear enough, but the current understanding is like this.