micronaut-projects / micronaut-projects/micronaut-data
Confusing error message if using @Repository in a JDBC project
- Dominant language
- Java
- Stars
- 482
- Forks
- 229
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 32
Description
### Expected Behavior
The error should say something like:
`Cannot use a repository annotated with @Repository in a JDBC project, please use @JdbcRepository(dialect = ...) instead.`
### Actual Behaviour
The Micronaut Data docs are a bit confusing w.r.t. how to annotate repository interfaces. The docs start by saying (under "shared concepts") that you have to annotate them with `@Repository` which makes sense, but in fact if you use JDBC directly (no JPA/Hibernate) the repository must be annotated with `@JdbcRepository`. This is explained later but it's easy to miss and if you do, you get an exception with a message like this:
`No backing RepositoryOperations configured for repository. Check your configuration and try again`
This is pretty confusing. The problem isn't in the app config file, it's not clear what a "backing RepositoryOperations" is or why none is configured, and the generic "check your configuration and try again" advice is so vague it's nearly non-actionable.
### Steps To Reproduce
1. Set up a JDBC only Micronaut Data project.
2. Write a repository that inherits from e.g. `GenericRepository` and is annotated using `@Repository`
3. Run the app.
4. Be puzzled by the resulting message.
### Environment Information
_No response_
### Example Application
_No response_
### Version
4.4.4
Contributor guide
Research direction
The issue names no source file or test; start by reproducing the JDBC-only setup with a GenericRepository annotated with @Repository, then trace the resulting "No backing RepositoryOperations configured" exception. Done means the failure clearly explains that JDBC repositories should use @JdbcRepository(dialect = ...) and includes a regression test for the message.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, sql
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100