Browse Source

Fix NPE in `CrudRepositoryExtensions`.

Closes #3187
pull/3277/head
Oscar Hernandez 1 year ago committed by Mark Paluch
parent
commit
4ea94056cc
No known key found for this signature in database
GPG Key ID: 55BC6374BAA9D973
  1. 5
      src/main/kotlin/org/springframework/data/repository/CrudRepositoryExtensions.kt

5
src/main/kotlin/org/springframework/data/repository/CrudRepositoryExtensions.kt

@ -19,8 +19,9 @@ package org.springframework.data.repository
* Retrieves an entity by its id. * Retrieves an entity by its id.
* *
* @param id the entity id. * @param id the entity id.
* @return the entity with the given id or `null` if none found * @return the entity with the given id or `null` if none found.
* @author Sebastien Deleuze * @author Sebastien Deleuze
* @author Oscar Hernandez
* @since 2.1.4 * @since 2.1.4
*/ */
fun <T, ID> CrudRepository<T, ID>.findByIdOrNull(id: ID): T? = findById(id!!).orElse(null) fun <T, ID: Any> CrudRepository<T, ID>.findByIdOrNull(id: ID): T? = findById(id).orElse(null)

Loading…
Cancel
Save