I'm new to Spring WebFlux reactive. I use R2DBC postgresql. I have a repository like that:
public interface BookRepository extends ReactiveCrudRepository<Book, Long> {
}
Now I want to add custom method to query by many complicated conditions:
public interface CustomBookRepository extends BookRepository {
Flux<Book> findByVeryComplicatedCondition(MyCriteriaDto criteria);
}
My implementation:
public class CustomBookRepositoryImpl extends CustomBookRepository {
//How to get it?
EntityManager em;
@Override
public Flux<Book> findByVeryComplicatedCondition(MyCriteriaDto criteria) {
Query query = em.createQuery("SELECT b from Book b WHERE (VERY COMPLICATED CONDITIONS)");
//What next?
}
}
My questions are in the code above:
- How to obtain an EntityManager?
- How to get Flux from HQL query I built?
When I ask these questions, I mean "How to do this with Spring reactive/r2dbc way", not "How to do this normal way with JDBC"
question from:
https://stackoverflow.com/questions/65950985/r2dbc-reactivecrudrepository-how-to-write-jpql-hql 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…