Show HN: A library for finding origin and context of JPA issued SQL statements
github.com
github.com
That's why I decided to write JPlusOne open surce library which would help with easy finding origin and context of JPA issued SQL statements. JPlusOne can generate report for each integration test containing complete tree of JPA persistence related activity or just situations when i.e. lazy loading is occurring, potentially leading to N+1 SELECT problem. Moreover JPlusOne provides API which allows to write tests checking how effectively, from performance point of view, your application is using JPA in context of some business operation (i.e. assert amount of lazy loading operations, or SQL statements in general). I hope you find it useful. Any feedback will be appreciated. Thanks.
So far I was investigating the use of Sniffy ( https://github.com/sniffy/sniffy ) which provides assertion capabilities on the number of queries during the runtime of a JUnit integration test. I'm pairing this with the rest of my JUnit 5 integration test stack (Test Containers, DBUnit, Database Rider and Flyway) which looks promising.
Unfortunately your tool seems to be closely coupled with Spring, correct? Is there a possibility of extracting some of the functionality to work independently of it? I'm thinking of JEE/MicroProfile/CDI based environments, e.g. Quarkus.
There’s also Hypersistence Optimizer. It does a lot more than just identifying N+1 issues. It’s paid but I think it also has a free option. The author is one of the creator of Hibernate and puts out amazing material on JPA and Hibernate. Strongly suggest to check out his stuff