|
1 | 1 | [](https://lgtm.com/projects/g/Lemick/hibernate-spring-sql-query-count/context:java) |
2 | 2 | # Hibernate SQL Query Assertions for Spring |
3 | 3 |
|
4 | | -Hibernate is a powerful ORM, but you need to have control over the executed SQL queries to avoid **huge performance problems** (N+1 selects, silent updates, batch insert not working...) |
| 4 | +Hibernate is a powerful ORM, but you need to have control over the executed SQL queries to avoid **huge performance problems** (N+1 selects, batch insert not working...) |
5 | 5 |
|
6 | 6 | You can enable SQL query logging, this is a great help in dev, but not in production. This tool helps you to count the **executed SQL queries by Hibernate in your integration tests**. |
7 | 7 |
|
@@ -41,14 +41,22 @@ The assertion will work seamlessly whether you're testing Spring repositories or |
41 | 41 | => '/* insert com.lemick.demo.entity.PostComment */ insert into post_comment (id, blog_post_id, content) values (default, ?, ?)' |
42 | 42 |
|
43 | 43 | ## How to integrate |
44 | | -1. Register the integration with Hibernate, you just need to add this key in your configuration (here for yml): |
| 44 | +1. Import the dependency |
| 45 | + |
| 46 | + <dependency> |
| 47 | + <groupId>com.mickaelb</groupId> |
| 48 | + <artifactId>hibernate-query-asserts</artifactId> |
| 49 | + <version>1.0.0</version> |
| 50 | + </dependency> |
| 51 | + |
| 52 | +2. Register the integration with Hibernate, you just need to add this key in your configuration (here for yml): |
45 | 53 |
|
46 | 54 | spring: |
47 | 55 | jpa: |
48 | 56 | properties: |
49 | 57 | hibernate.session_factory.statement_inspector: com.mickaelb.integration.hibernate.HibernateStatementCountInspector |
50 | 58 |
|
51 | | -2. Register the Spring TestListener that will launch the SQL inspection if the annotation is present: |
| 59 | +3. Register the Spring TestListener that will launch the SQL inspection if the annotation is present: |
52 | 60 |
|
53 | 61 | * By adding the listener on each of your integration test: |
54 | 62 |
|
|
0 commit comments