spring-projects / spring-projects/spring-data-mongodb
Reactive Mongo with Kotlin suspend functions
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.7k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
When writing ReactiveMongoRepository/ReactiveCrudRepository with spring-boot-starter-data-mongodb-reactive and declaring suspend find function with non-nullable kotlin return types, the repository returns null when it can't find an entity instead of EmptyResultDataAccessException.
Here is the fun declaration:
suspend fun findSomeEntitiesById(id: Long): SomeEntity
And this test prints null when called with id that does not exists:
@Test
internal fun returnsNllReference() {
runBlocking {
println(repositoryMy.findSomeEntitiesById(123))
}
}
If I replace spring-boot-starter-data-mongodb-reactive with spring-boot-starter-data-r2dbc, it throws
org.springframework.dao.EmptyResultDataAccessException: Result must not be null!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the ReactiveMongoRepository/ReactiveCrudRepository suspend function entry point and compare its missing-entity behavior with the spring-boot-starter-data-r2dbc example. Reproduce the non-nullable Kotlin query using id 123; done means a missing entity raises EmptyResultDataAccessException instead of returning null, with a regression test covering that case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin, mongodb, spring
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100