Why use Querydsl?

I am new to JPA , JPQL , Hibernate , Querydsl , and now I saw this in my project using Querydsl to query, and I wonder why this approach was chosen. Therefore, you can be sure why it is in my project, but you can say why and in which situations Querydsl is preferred. Why can we use simple JPQL instructions?

+6
source share
2 answers
  • You can use code completion in the IDE
  • IDE refactoring tools work (more or less)
  • type safe
  • (almost) syntax safe
  • the compiler generates errors during compilation of the wrong types, etc. vs Hibernate only complains about the first launch
  • Consistency, you can use the same principles to query JPA, MongoDB, Collections ...
+11
source

I would like to counterpoint to using QueryDSL.

I do not like to use QueryDSL for the following reasons:

  • You need to frequently compile the project to support updated Q classes
  • You need to configure the IDE so that the Q classes generated by target are treated like regular classes.
  • I already saw how the IDE "got lost" and no longer recognized Q classes
  • I already created simple QueryDSL statements that generated really strange and unpredictable SQL .

Even being end-user friendly, I prefer to use JPQL because it is closer to the generated SQL and more predictable.

But compared to the criteria, I prefer QueryDSL.

-1
source

Source: https://habr.com/ru/post/1210966/


All Articles