Reputation: 219
I'm trying to use Spring data JDBC with Query DSL in Kotlin. This is my repository
@Repository
interface UserRepository : PagingAndSortingRepository<User, Int>, QuerydslPredicateExecutor<User> {}
My entity is a simple data object
@Entity
@Table(name = "user")
data class User(
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "user_id_seq")
@SequenceGenerator(name = "user_id_seq", sequenceName = "user_id_seq", allocationSize = 1)
val id: Int? = null,
val name: String,
val surname: String)
I've added these lines to my build.gradle
implementation("com.querydsl:querydsl-sql-spring:4.4.0") {
exclude group: 'joda-time', module: 'joda-time'
}
kapt "com.querydsl:querydsl-apt:4.4.0:jpa"
I've added the @EnableJdbcrepositories
annotation in my Spring application
But when I try to start my application I get this error:
Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository' defined in my.tests.querydsl.repositories.UserRepository defined in @EnableJdbcRepositories declared on
JdbcRepositoriesRegistrar.EnableJdbcRepositoriesConfiguration: 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 User!
I tried also to remove @EnableJdbcrepositories
annotation but the error persists.
What I'm doing wrong? I'm missing some dependency?
Thanks
Upvotes: 1
Views: 1835
Reputation: 6400
Infobip Spring Data Querydsl provides QuerydslPredicateExecutor fragment support for Spring Data JDBC (among other things).
With it, UserRepository
definition should work as is defined, check out the module README.md JDBC section for details.
If you need SQLQuery
, SQLUpdateClause
or delete with Predicate
support don't miss the QuerydslJdbcFragment.
Upvotes: 1
Reputation: 11
The Spring-Data book says that only Spring Data JPA and MongoDB support QuerydslPredicateExecutor
Upvotes: 0