https://github.com/youssefgamalmohamed/spring-jpa-database-locking
This Repository Contains Implementation for Database Locking with Spring Data JPA
https://github.com/youssefgamalmohamed/spring-jpa-database-locking
database-locking docker lombok postgresql spring-boot spring-data-jpa
Last synced: about 2 months ago
JSON representation
This Repository Contains Implementation for Database Locking with Spring Data JPA
- Host: GitHub
- URL: https://github.com/youssefgamalmohamed/spring-jpa-database-locking
- Owner: youssefGamalMohamed
- Created: 2025-03-04T22:28:04.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-03-04T22:41:54.000Z (12 months ago)
- Last Synced: 2025-03-04T23:28:19.061Z (12 months ago)
- Topics: database-locking, docker, lombok, postgresql, spring-boot, spring-data-jpa
- Language: Java
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# spring-jpa-database-locking
This Repository Contains Implementation for Database Locking with Spring Data JPA
## Tools and Technologies Used
- Java
- Spring Boot
- Spring Data JPA
- Hibernate
- Maven
- H2 Database (for testing)
- JMeter (for performance testing)
## Setup
1. Clone the repository:
```sh
git clone https://github.com/your-repo/spring-jpa-database-locking.git
```
2. Navigate to the project directory:
```sh
cd spring-jpa-database-locking
```
3. Build the project:
```sh
./mvnw clean install
```
## Usage
1. Run the application:
```sh
./mvnw spring-boot:run
```
2. Access the application at `http://localhost:8080`.
## Examples
### Pessimistic Locking
```java
// ...existing code...
@Entity
public class ExampleEntity {
// ...existing code...
@Version
private Long version;
// ...existing code...
}
```
### Optimistic Locking
```java
// ...existing code...
@Entity
public class ExampleEntity {
// ...existing code...
@Version
private Long version;
// ...existing code...
}
```
## Testing
### Testing Optimistic Locking with JMeter
1. Open JMeter.
2. Load the provided JMeter test plan located at `Database Locking JPA Test Plan.jmx`.
3. Start the test plan to simulate concurrent updates and observe the results.
## Contributing
1. Fork the repository.
2. Create a new branch (`git checkout -b feature-branch`).
3. Commit your changes (`git commit -am 'Add new feature'`).
4. Push to the branch (`git push origin feature-branch`).
5. Create a new Pull Request.
## License
This project is licensed under the MIT License.