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>

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

Availability

By default bundled with

IntelliJ IDEA 2024.1, Qodana for JVM 2024.1,

Can be installed with plugin

Spring Data, 241.18072

Last modified: 18 June 2024