https://github.com/sterlp/hibernate-test-asserts
HibernateAsserts helps verifying JPA characteristics in Hibernate projects, ensuring correct fetch joins, relationships, and transaction boundaries to prevent performance issues and errors.
https://github.com/sterlp/hibernate-test-asserts
assert hibernate jpa junit lazy-loading query test testing transactions
Last synced: about 2 months ago
JSON representation
HibernateAsserts helps verifying JPA characteristics in Hibernate projects, ensuring correct fetch joins, relationships, and transaction boundaries to prevent performance issues and errors.
- Host: GitHub
- URL: https://github.com/sterlp/hibernate-test-asserts
- Owner: sterlp
- License: mit
- Created: 2025-01-19T16:30:29.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-20T18:35:15.000Z (over 1 year ago)
- Last Synced: 2025-03-20T03:41:28.877Z (over 1 year ago)
- Topics: assert, hibernate, jpa, junit, lazy-loading, query, test, testing, transactions
- Language: Java
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/sterlp/hibernate-test-asserts/actions/workflows/maven.yml)
# Setup
- [Maven](https://central.sonatype.com/search?q=hibernate-asserts&namespace=org.sterl.test)
- [Blog](https://sterl.org/2021/08/jpa-model-testing-with-hibernate-statistics/)
```xml
org.sterl.test
hibernate-asserts
1.0.x
test
```
# Example
```java
@Configuration
public static class Config {
@Bean
HibernateAsserts hibernateAsserts(EntityManager entityManager) {
return new HibernateAsserts(entityManager);
}
}
@Autowired
private PersonService subject;
@Autowired
private HibernateAsserts hibernateAsserts;
@Test
void testCreatePerson() {
// GIVEN
var name = "Paul";
// WHEN
subject.create(name);
// THEN
hibernateAsserts
.assertInsertCount(1)
.assertUpdateCount(0)
.assertTrxCount(1);
}
```