Why to use Querydsl?

  • You can use code completion in IDE
  • IDE refactoring tools work (more-or-less)
  • type-safe
  • (almost)syntax-safe
  • compiler generates errors on compile time of wrong types etc vs Hibernate complains just on first run
  • Consistency, you can use same principles to query JPA, MongoDB, Collections...

I would like to make a counterpoint to the QueryDSL usage.

I don't like to use QueryDSL for the follow reasons:

  • You need to compile the project frequently to maintain the Q classes updated
  • You need to setup the IDE to consider the Q classes generated on target as normal classes.
  • I have already seen the IDE "get lost" and no longer recognize the Q classes
  • I already create simple QueryDSL statements that generated really weird and not predictable SQLs.

Even being friendly for final users, I prefer to use JPQL because it's more closer to the generated SQL and more predictable.

But compared to Criteria, I prefer QueryDSL.