Database optimistic lock implementation method and system based on SpringBoot + JPA
An implementation method and database technology, applied in the database field, can solve problems such as data duplication, and achieve the effects of avoiding data duplication, promoting the use value, and using a wide range of applications.
- Summary
- Abstract
- Description
- Claims
- Application Information
AI Technical Summary
Problems solved by technology
Method used
Image
Examples
Embodiment 1
[0049] as attached figure 1 As shown, the database optimistic lock implementation method based on SpringBoot+JPA of the present invention, the method steps are as follows:
[0050]S1. Create a lock_table table: create a new lock_table table in the database, and the lock_table is used to store lock data information; the lock data information includes lock name (lock_name), version number (version) and status (lock_state). The lock_table table structure is designed as follows:
[0051] lock_name version lock_state lock name version number state
[0052] S2. Operation lock: lock the concurrent transaction operation, and add the data information of the lock in the lock_table table in the database; the details are as follows:
[0053] S201. Obtaining a lock: query the lock_table table to obtain information about the lock, and ensure that the corresponding process acquires the lock; the steps are as follows:
[0054] (1) Query the lock information in lo...
Embodiment 2
[0063] as attached figure 2 Shown, the database optimistic locking system based on SpringBoot+JPA of the present invention, this system comprises,
[0064] The lock_table table creation module is used to create a new lock_table table in the database, and the lock_table is used to store lock data information; the lock data information includes lock name (lock_name), version number (version) and status (lock_state).
[0065] The locking operation module is used to lock the concurrent transaction operation, and increase the data information of the lock in the lock_table table in the database;
[0066] Among them, the locking operation module includes,
[0067] The lock acquisition module is used to query the lock_table table to acquire lock information, and ensure that the corresponding process acquires the lock;
[0068] The transaction execution module is used to continue the execution of the corresponding process and complete the transaction operation on the database;
[0...
Embodiment 3
[0078] Take the concurrent transaction operation lock A as an example:
[0079] Add the data of lock A in the lock_table table of the database. The execution steps of concurrent transaction locking are as follows:
[0080] 1) Acquiring a lock: Query the information of lock A in lock_table. If the version number of lock A is less than the current date and the status is "unlocked", execute the update statement to update the status of lock A to "locked", and the update statement adds @ Transactional, @Modifying annotations, after successful execution, the return value is the number of updated data items. If the number of data items updated by process A is greater than 0, it means that process A has acquired the lock. Process A continues to execute the next step, and other processes that have not acquired the lock terminate execution.
[0081] 2) Executing a transaction: Process A continues to execute and completes the transaction operation on the database.
[0082] 3) Release...
PUM
Abstract
Description
Claims
Application Information
- R&D Engineer
- R&D Manager
- IP Professional
- Industry Leading Data Capabilities
- Powerful AI technology
- Patent DNA Extraction
Browse by: Latest US Patents, China's latest patents, Technical Efficacy Thesaurus, Application Domain, Technology Topic, Popular Technical Reports.
© 2024 PatSnap. All rights reserved.Legal|Privacy policy|Modern Slavery Act Transparency Statement|Sitemap|About US| Contact US: help@patsnap.com