Open
Description
Hello,
I was following the DTO Projection documentation but can't make it work.
My set up : spring-boot 2.7.3 (data couchbase 4.4.2)
First, this documentation has example using spring data JPA (@Entity
and @OneToOne
annotations). Is it normal ?
Second, here is my simple test and the exception I get :
Person document :
@Document
@Scope("dev")
@Collection("person")
data class Person(
@field:Id
val id: String,
@field:Field
val name: String
)
Projection interface :
interface Name {
fun getName(): String
}
Person repository :
interface PersonRepository : ReactiveCouchbaseRepository<Person, String> {
fun findByName(name: String): Flux<Name>
}
Exception :
java.lang.IllegalArgumentException: returnType must not be null!
at org.springframework.util.Assert.notNull(Assert.java:201) ~[spring-core-5.3.22.jar:5.3.22]
Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Error has been observed at the following site(s):
*__checkpoint ⇢ org.springframework.boot.actuate.metrics.web.reactive.server.MetricsWebFilter [DefaultWebFilterChain]
*__checkpoint ⇢ HTTP POST "/person" [ExceptionHandlingWebHandler]
Original Stack Trace:
at org.springframework.util.Assert.notNull(Assert.java:201) ~[spring-core-5.3.22.jar:5.3.22]
at org.springframework.data.couchbase.core.ReactiveFindByQueryOperationSupport$ReactiveFindByQuerySupport.as(ReactiveFindByQueryOperationSupport.java:134) ~[spring-data-couchbase-4.4.2.jar:4.4.2]
at org.springframework.data.couchbase.repository.query.AbstractReactiveCouchbaseQuery.lambda$getExecutionToWrap$1(AbstractReactiveCouchbaseQuery.java:122) ~[spring-data-couchbase-4.4.2.jar:4.4.2]
at org.springframework.data.couchbase.repository.query.ReactiveCouchbaseQueryExecution$ResultProcessingExecution.execute(ReactiveCouchbaseQueryExecution.java:77) ~[spring-data-couchbase-4.4.2.jar:4.4.2]
at org.springframework.data.couchbase.repository.query.AbstractReactiveCouchbaseQuery.doExecute(AbstractReactiveCouchbaseQuery.java:91) ~[spring-data-couchbase-4.4.2.jar:4.4.2]
at org.springframework.data.couchbase.repository.query.AbstractCouchbaseQueryBase.execute(AbstractCouchbaseQueryBase.java:133) ~[spring-data-couchbase-4.4.2.jar:4.4.2]
at org.springframework.data.couchbase.repository.query.AbstractCouchbaseQueryBase.execute(AbstractCouchbaseQueryBase.java:113) ~[spring-data-couchbase-4.4.2.jar:4.4.2]
at org.springframework.data.repository.core.support.RepositoryMethodInvoker.doInvoke(RepositoryMethodInvoker.java:137) ~[spring-data-commons-2.7.2.jar:2.7.2]
at org.springframework.data.repository.core.support.RepositoryMethodInvoker.invoke(RepositoryMethodInvoker.java:121) ~[spring-data-commons-2.7.2.jar:2.7.2]
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:160) ~[spring-data-commons-2.7.2.jar:2.7.2]
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:139) ~[spring-data-commons-2.7.2.jar:2.7.2]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.22.jar:5.3.22]
at org.springframework.data.couchbase.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:141) ~[spring-data-couchbase-4.4.2.jar:4.4.2]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.22.jar:5.3.22]
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97) ~[spring-aop-5.3.22.jar:5.3.22]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.22.jar:5.3.22]
at org.springframework.data.repository.core.support.MethodInvocationValidator.invoke(MethodInvocationValidator.java:99) ~[spring-data-commons-2.7.2.jar:2.7.2]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.22.jar:5.3.22]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215) ~[spring-aop-5.3.22.jar:5.3.22]
at jdk.proxy2/jdk.proxy2.$Proxy101.findByName(Unknown Source) ~[na:na]
at com.rbleuse.spring.reactive.couchbase.service.PersonService.getProjectionByName(PersonService.kt:13) ~[main/:na]
Is the documentation is up to date, and can we use projection with spring data couchbase ?