Search code examples
springspring-bootcouchbasespring-data-couchbase

SpringDataCouchbase @Query on SpringBoot 2.3.0 not working as before


I migrated a couple of days ago to SpringBoot 2.3.0 to be able to use SpringDataCouchbase 4.0.0 and its fully reactive approach with the ReactiveTemplate. However, a simple @Query that was working fine before (SpringBoot 2.2.6) is throwing errors. This is the query:

@Query("#{#n1ql.selectEntity} WHERE docType = '" + NotificationMq.DOC_TYPE + "'")
Flux<NotificationMq> myCustomMethod();

Everything (Configuration and field annotations were updated following the documentation) but it looks like the @Query annotation is not taking into account to override the string derivation query. The current error is:

org.springframework.data.mapping.PropertyReferenceException: No property myCustomMethod found for type NotificationMq!
    at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:94) ~[spring-data-commons-2.3.0.RELEASE.jar:2.3.0.RELEASE]
    at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:382) ~[spring-data-commons-2.3.0.RELEASE.jar:2.3.0.RELEASE]
    at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:358) ~[spring-data-commons-2.3.0.RELEASE.jar:2.3.0.RELEASE]
    at org.springframework.data.mapping.PropertyPath.lambda$from$0(PropertyPath.java:311) ~[spring-data-commons-2.3.0.RELEASE.jar:2.3.0.RELEASE]
    at java.util.concurrent.ConcurrentMap.computeIfAbsent(ConcurrentMap.java:324) ~[na:1.8.0_144]
    at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:293) ~[spring-data-commons-2.3.0.RELEASE.jar:2.3.0.RELEASE]
    at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:276) ~[spring-data-commons-2.3.0.RELEASE.jar:2.3.0.RELEASE]
    at org.springframework.data.repository.query.parser.Part.<init>(Part.java:82) ~[spring-data-commons-2.3.0.RELEASE.jar:2.3.0.RELEASE]
    at org.springframework.data.repository.query.parser.PartTree$OrPart.lambda$new$0(PartTree.java:251) ~[spring-data-commons-2.3.0.RELEASE.jar:2.3.0.RELEASE]

My repository is defined as usual:

@Repository
public interface NotificationMqRepository extends ReactiveSortingRepository<NotificationMq, String>

Any ideas about what could be wrong? or how to determine if the @Query is overriding and generating the query?

Thanks in advance for your help.


Solution

  • Following the answer from the Couchbase forum:

    Couchbase Answer

    The @Query annotation is not supported in version 4.0.0 but hopefully on version 4.0.1.