Search code examples
jpajpqlquerydsl

Why to use Querydsl?


I am new to JPA, JPQL, Hibernate, Querydsl and now I saw that in my project is used Querydsl for querying and I am wondering why this approach has been chosen. So you can be for sure why exactly is in my project but you can tell why and in what situations Querydsl is preferred. Why we can use simple JPQL statements?


Solution

    • 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...