Fix NPE in CrudRepositoryExtensions.

Closes #3187
This commit is contained in:
Oscar Hernandez
2024-10-24 13:12:51 +02:00
committed by Mark Paluch
parent b4d2391cdb
commit 4ea94056cc

View File

@@ -19,8 +19,9 @@ package org.springframework.data.repository
* Retrieves an entity by its 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 Oscar Hernandez
* @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)