Inspectopedia 2025.3 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>

Locating this inspection

By ID

Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.

SpringDataRepositoryMethodReturnTypeInspection
Via Settings dialog

Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.

Settings or Preferences | Editor | Inspections | Spring | Spring Data

Inspection ID: SpringDataRepositoryMethodReturnTypeInspection

Suppressing Inspection

You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:

//noinspection SpringDataRepositoryMethodReturnTypeInspection

More detailed instructions as well as other ways and options that you have can be found in the product documentation:

Inspection Details

By default bundled with:

IntelliJ IDEA 2025.3, Qodana for JVM 2025.3,

Last modified: 03 December 2025