Inspectopedia Help

Spring Data repository method return type errors

Reports Spring Data CRUD repository methods with incorrect return types.

The following return types are supported:

  • void

  • Primitive types

  • Wrapper types

  • T when the query method is expected to return one result at most. Returns null if there are no results and throws IncorrectResultSizeDataAccessException if there is more than one result.

  • java.util.List or any common Iterable type

  • java.util.stream.Stream

  • java.util.Optional or scala.Option when the query method is expected to return one result at most. Returns Optional.empty() or Optional.absent() if there are no results and throws IncorrectResultSizeDataAccessException if there is more than one result.

  • io.micronaut.data.model.Page

  • io.micronaut.data.model.Slice

  • java.util.concurrent.Future, java.util.concurrent.CompletableFuture, or ListenableFuture if the method is annotated with @Async and Spring asynchronous method execution is enabled

  • GeoResults<T>, GeoResult<T>, or GeoPage<T>

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Spring Data, 233.SNAPSHOT

Last modified: 13 July 2023