Zum Inhalt springen

N+1 Query (ARCH8050)

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

Key kotlin.orm.n-plus-one-query · Severity warning · Category orm

Flags a repository or DAO read (findById, find*, get*, query) executed inside a loop - one query per iteration. A batch/bulk read is the fix, not the defect, and is excepted.

for (id in orderIds) {
val order = orderRepository.findById(id)
}
val orders = orderRepository.findAllById(orderIds)

Load the set in one query (findAllById, an IN clause, a join) before the loop.