---
title: "Discussion on \"Catch N+1 Queries in Spring Boot Tests by Asserting the Query Count\" | Hashnode"
description: "Discussion on \"Catch N+1 Queries in Spring Boot Tests by Asserting the Query Count\". A naive listing of 10 customers touched lazy orders and used 11 prepared statements and 10 collection fetches. @EntityGraph and JOIN FETCH each used 1 statement and 0 collection fetches."
url: "https://hashnode.com/posts/catch-n-plus-1-queries-spring-boot-tests/6b090b1e8a3e07d7992dace4"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Catch N+1 Queries in Spring Boot Tests by Asserting the Query Count](https://gowthammuthuvel.hashnode.dev/catch-n-plus-1-queries-spring-boot-tests?utm_source=hashnode&utm_medium=feed)

A naive listing of 10 customers touched lazy orders and used 11 prepared statements and 10 collection fetches. @EntityGraph and JOIN FETCH each used 1 statement and 0 collection fetches.

1d ago · 9 min read · gowthammuthuvel.hashnode.dev  
Read the article

-   [#java](https://hashnode.com/tag/java)
-   [#testing](https://hashnode.com/tag/testing)
-   [#spring-boot](https://hashnode.com/tag/spring-boot)
-   [#hibernate](https://hashnode.com/tag/hibernate)
-   [#jpa](https://hashnode.com/tag/jpa)

## Written by

[Gowtham Muthuvel](https://hashnode.com/@GowthamMuthuvel)

@GowthamMuthuvel

  
[View profile](https://hashnode.com/@GowthamMuthuvel)

Full-stack developer | Java, Spring Boot, React | Senior Backend Developer

## Responses 1

Markdown supported · ⌘↵ to post

[Adam Lewis](https://hashnode.com/@nark3d)

[13h ago](https://hashnode.com/posts/catch-n-plus-1-queries-spring-boot-tests/6b090b1e8a3e07d7992dace4/comment/6b0aa28f6212949bcce5cfca)

Nice one, the part about the counter belonging to the SessionFactory is what I'd have got wrong.
