Spring ReactiveCrudRepository ExistsQuery method returns null

reactivecrudrepository example
reactivemongorepository
existsbyid
reactivemongotemplate
spring data
reactivecrudrepository maven
findallbyid
reactivecrudrepository save not working

Any idea why the following code would return a mono of null? I realize why the contract would allow it but I would expect the Spring code to return either a true or a false.

public interface SampleRepository extends ReactiveCrudRepository<Sample, String> {
    @ExistsQuery("{ userId: ?0 }")
    Mono<Boolean> existsWithUserId(String userId);

    @Query("{ userId: ?0 }")
    Mono<Sample> findWithUserId(String userId);
}

You can change Mono<Boolean> to boolean and it will return only true or false

public interface SampleRepository extends ReactiveCrudRepository<Sample, String> {
    @ExistsQuery("{ userId: ?0 }")
    boolean existsWithUserId(String userId);

    @Query("{ userId: ?0 }")
    boolean findWithUserId(String userId);
}

ReactiveCrudRepository (Spring Data Core 2.3.0.RELEASE API), Uses the first emitted element to perform the exists-query. Parameters: id - must not be null. Returns: Mono emitting true if an entity with the given id exists, false  sort - must not be null. Returns: all entities sorted by the given options. Throws: IllegalArgumentException - in case the given Sort is null.

Maybe this was a bug in a previous version. With Spring Boot 2.0.5 (Spring 5.0.9, Spring Data 2.0.10) and the reactive mongo driver 3.8.2 it works fine for me - null is never returned.

Please note that I explicitly use the newer mongo-driver-async 3.8.2 instead of the current default version since in the latter another bug is contained that is fixed in the newer version.

Spring Data MongoDB, Null Handling of Repository Methods. As of Spring Data 2.0, repository CRUD methods that return an individual aggregate instance use Java 8's Optional to  Scott White. Chief Technology Officer & Architect. 2 Spring ReactiveCrudRepository ExistsQuery method returns null Jul 10 '18. 1 Are NHibernate lists loaded on

If the repository can't find the entry, it will return a Mono

The Exists Query in Spring Data, Learn how to check if an object exists in a database using Spring Data and JPA. The JpaRepository interface exposes the existsById method that count query based on the model property, evaluate the return value, and  mxg. Professional Software Developer at Neofonie. 0 Spring ReactiveCrudRepository ExistsQuery method returns null Oct 10 '18. Badges (6) Gold

Spring Data for Apache Cassandra, Null Handling of Repository Methods. As of Spring Data 2.0, repository CRUD methods that return an individual aggregate instance use Java  As stated in the title I'm not been able to insert or update records in my Postgres database. I just started working with spring and kotlin so there might be some pretty basic configuration that it's missing. Thanks in advance. Here is my code base. UserRepository @Repository interface UserRepository : ReactiveCrudRepository<User, Int> {}

NullPointerException on TextView from Fragment, dataTextTab1); return rootView; } // TODO: Rename method, update Spring ReactiveCrudRepository ExistsQuery method returns null. July 22  entities - must not be null. Returns: the saved entity; findAll <S extends T> reactor.core.publisher.Flux<S> findAll(Example<S> example) Specified by: findAll in interface ReactiveQueryByExampleExecutor<T> findAll <S extends T> reactor.core.publisher.Flux<S> findAll(Example<S> example, Sort sort)

Binary field data auto converting to null binding when using , and a supporting entity class coupled with a ReactiveCrudRepository Why is Spring Data R2dbc attempting to do a bindNull given the argument is not null? Method.invoke(Method.java:498) at org.junit.runners.model. entities - must not be null nor must it contain null. Returns: the saved entities; will never be null. The returned Iterable will have the same size as the Iterable passed as an argument. Throws: IllegalArgumentException - in case the given entities or one of its entities is null. findById Optional<T> findById(ID id)

Comments
  • Even if this would work it is not a good idea because it would require to block the caller until the mongo query returns which is the opposite of what you usually want to achieve using a ReactiveCrudRepository in a reactive stack.