The best way to fetch entities with JPA and Hibernate

Поділитися
Вставка
  • Опубліковано 1 гру 2022
  • In this video, we are going to talk about fetching JPA and Hibernate entities.
    First, I'm going to explain how you fetch entities directly via their entity identifier or natural identifier.
    Afterward, we are going to see how we can fetch entities via JPQL, SQL, and Criteria API queries.
    In the end, I'm going to explain how the JPA entity Metamodel works and why you should use it when building dynamic queries using the JPA Criteria API.
  • Наука та технологія

КОМЕНТАРІ • 8

  • @vaheharutyunyan966
    @vaheharutyunyan966 Рік тому +1

    As always very good Video Vlad, Thank you.

    • @vladmihalcea
      @vladmihalcea  Рік тому

      You're welcome and stay tuned for more

  • @yvip
    @yvip Рік тому +2

    Thank you very good info

  • @vaheharutyunyan966
    @vaheharutyunyan966 Рік тому

    I find JPA Query DSL lib much much better than Criteria API, I don't know why people use Criteria API. What do you think about Query DSL Vlad ?

    • @vladmihalcea
      @vladmihalcea  Рік тому

      I use Blaze Persistence instead of Criteria API:
      vladmihalcea.com/blaze-persistence-jpa-criteria-queries/
      QueryDSL was abandoned for many years, and only currently got some updates. For native SQL, I'd rather use jOOQ, as it's superior to QueryDSL in any way.

    • @vaheharutyunyan966
      @vaheharutyunyan966 Рік тому

      @@vladmihalcea It seams Blaze does not give TypeSafe queries like QueryDSL, what is other disadvantage of QueryDSL beside not being maintained actively ?

    • @vladmihalcea
      @vladmihalcea  Рік тому

      @@vaheharutyunyan966 Blaze Persistence has typed queries using the JPA Metamodel
      vladmihalcea.com/bulk-update-delete-blaze-persistence/
      However, jOOQ is even more powerful than Blaze. You can even use it to fetch efficiently multiple one-to-many relations without a Cartesian Product:
      blog.jooq.org/jooq-3-15s-new-multiset-operator-will-change-how-you-think-about-sql/
      It's also amazing for stored procedures too:
      vladmihalcea.com/jooq-facts-sql-functions-made-easy/
      Plus, it offers Keyset Pagination, Recursive CTE, Pivot, Window Functions, Lateral Joins, JSON, and many more features.
      And it's maintained and improved constantly.