yannbriancon / spring-hibernate-query-utils

Library giving tools to detect N+1 queries and count the queries generated with Spring and Hibernate
MIT License
135 stars 15 forks source link

False Positive on EAGER detection #28

Open javaboy79 opened 3 years ago

javaboy79 commented 3 years ago

False postive EAGER queries are being reported when more than one proxy is in the application stack. For example, a Spring RMI layer in front of the Spring Data Repository call. The RMI layer would be the top-most proxy and be detected first, resulting in isolated/unrelated query methods being considered for eager fetches. The code here increments based on the proxy name, which is detected incorrectly. This seems to stem from the code in getProxyMethodName()

Why did you choose to walk the stack backward (top-down), vs starting at the bottom and going up? If it were reversed, wouldn't it find the more accurate proxy method or would that lead to missed detections?

This is possibly related to #26, but not isolated to testing.

Consider improving the proxy detection by doing one of the following: