Skip to content

Improve error messages if a repository cannot be created #2341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spring-projects-issues opened this issue Oct 14, 2020 · 5 comments
Closed
Assignees
Labels
type: enhancement A general enhancement

Comments

@spring-projects-issues
Copy link

Tera opened DATACMNS-1812 and commented

I'm trying to use Spring data JDBC with Query DSL in Kotlin. This is my repository

 

@Repository
interface AgentRepository : PagingAndSortingRepository<Agent, Int>, QuerydslPredicateExecutor<Agent> {}

I've integrated these dependencies in my Gradle build:

implementation 'org.springframework.boot:spring-boot-starter-data-jdbc:2.3.3'
implementation("com.querydsl:querydsl-core:4.4.0") 
kapt "com.querydsl:querydsl-apt:4.4.0:jpa"

As soon as I try to start my application I get this error:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'agentRepository' defined in it.dove.braniac.repositories.AgentRepository defined in @EnableJdbcRepositories declared on BraniacApplication: Invocation of init method failed; nested exception is org.springframework.data.repository.query.QueryCreationException: Could not create query for public abstract long org.springframework.data.querydsl.QuerydslPredicateExecutor.count(com.querydsl.core.types.Predicate)! Reason: No property count found for type Agent!

I can't understand what I'm doing wrong and if there is an incompatibility between Spring Data JDBC and QueryDSL

 

The same issue happens if I try to change from PagingAndSortingRepository to simple CrudRepository


Affects: 2.3.4 (Neumann SR4)

@mp911de mp911de transferred this issue from spring-projects/spring-data-commons Jan 26, 2021
@mp911de
Copy link
Member

mp911de commented Jan 26, 2021

Moving to Spring Data JDBC

@schauder
Copy link
Contributor

Spring Data JDBC currently doesn't have Querydsl support.

I'll consider this a feature request to add Querydsl support.

@mp911de mp911de removed their assignment Jan 27, 2021
@mp911de
Copy link
Member

mp911de commented Feb 1, 2021

This ticket duplicates somewhat spring-projects/spring-data-relational#278. What we would like to do is to repurpose this ticket into providing a better error message if a Spring Data module doesn't support Querydsl (or Query by Example).

@mp911de mp911de self-assigned this Feb 1, 2021
@mp911de mp911de transferred this issue from spring-projects/spring-data-relational Mar 25, 2021
@mp911de
Copy link
Member

mp911de commented Mar 25, 2021

Moving to Spring Data Commons.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 25, 2021
@mp911de mp911de added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 25, 2021
@mp911de
Copy link
Member

mp911de commented Mar 25, 2021

An error message would look like:

Caused by: java.lang.IllegalStateException: Repository com.example.jdbcquerybyexample.DemoApplication$PersonRepository implements org.springframework.data.repository.query.QueryByExampleExecutor but JdbcRepositoryFactory does not support Query by Example!
	at org.springframework.data.repository.core.support.RepositoryFactorySupport$RepositoryValidator.validate(RepositoryFactorySupport.java:773) ~[spring-data-commons-2.5.0-GH-2341-SNAPSHOT.jar:2.5.0-GH-2341-SNAPSHOT]
	at org.springframework.data.repository.core.support.RepositoryFactorySupport.validate(RepositoryFactorySupport.java:507) ~[spring-data-commons-2.5.0-GH-2341-SNAPSHOT.jar:2.5.0-GH-2341-SNAPSHOT]

@mp911de mp911de changed the title Improve error message if store module doesn't support QuerydslPredicateExecutor Improve error message if store module doesn't support a well-known fragment interface Mar 25, 2021
mp911de added a commit that referenced this issue Mar 25, 2021
…agment interface.

We now throw a RepositoryCreationException (or subclass) when a repository cannot be created due to a missing fragment, a fragment without implementation or if a well-known fragment is not supported by the repository factory.

Closes #2341
@mp911de mp911de changed the title Improve error message if store module doesn't support a well-known fragment interface Improve error messages if a repository cannot be created Mar 26, 2021
mp911de added a commit that referenced this issue Mar 29, 2021
…agment interface.

We now throw a RepositoryCreationException (or subclass) when a repository cannot be created due to a missing fragment, a fragment without implementation or if a well-known fragment is not supported by the repository factory.

Throw QueryCreationException if QueryExecutorMethodInterceptor cannot resolve a RepositoryQuery.

Closes #2341
@mp911de mp911de added this to the 2.5 RC1 (2021.0.0) milestone Mar 29, 2021
mp911de added a commit that referenced this issue Mar 29, 2021
…agment interface.

We now throw a RepositoryCreationException (or subclass) when a repository cannot be created due to a missing fragment, a fragment without implementation or if a well-known fragment is not supported by the repository factory.

Throw QueryCreationException if QueryExecutorMethodInterceptor cannot resolve a RepositoryQuery.

Closes #2341
Original pull request: #2342.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
3 participants