JPA & Hibernate: Using the Optimal Query Approach & Projection

Поділитися
Вставка
  • Опубліковано 15 вер 2024
  • Using JPA and Hibernate, you can choose between various ways to query your data, and each of them supports one or more kinds of projections. That provides you with lots of options to implement your persistence layer. But which one fits your use case? And which one should you avoid if you want to optimize your persistence layer for performance?
    To answer these questions, we need to talk about the different ways to define a query. One of them is JPQL, of course. It’s a query language based on your domain model. But you can also use multiple proprietary and standardized APIs to create a query. Or you can execute native SQL queries if you need to use database-specific query features or define very complex queries.
    In this video, I will explain when you should use which approach to using optimal query approach and projection.
    If you are new here and you want to learn how to create your entity mappings with ease, build incredible efficient persistence layers with Hibernate and all types of other Java persistence related stuff, start now by subscribing and clicking the bell, so you don't miss anything.
    And if you have any topic or question related to Hibernate that you want to learn more about, please share it in the comment section below
    If you like this video, please give me your thumbs up and share it with your friends and co-workers.
    Links mentioned in the video-
    • Basic SQL ResultSet Mappings : thoughts-on-ja...
    • Complex SQL ResultSet Mappings : thoughts-on-ja...
    • Mapping DTO Projections : thoughts-on-ja...
    • Hibernate-specific Mappings : thoughts-on-ja...
    • How to select multiple scalar values in a Criteria Query : thoughts-on-ja...
    • Entities or DTOs - When should you use which projection? : thoughts-on-ja...
    • Native Queries - How to call native SQL queries with JPA & Hibernate : thoughts-on-ja...
    Like my channel? Subscribe!
    ➜ bit.ly/2cUsid8
    Join the free Member Library:
    goo.gl/dtyIIC
    Read the accompanying post: thoughts-on-ja...
    Want to connect with me?
    Blog: www.thoughts-on...
    Twitter: / thjanssen123
    Facebook: / thoughtsonjava
    #hibernate #JPA #Projection #OptimalQueryApproach

КОМЕНТАРІ • 7

  • @artrahman169
    @artrahman169 4 роки тому

    Its quite an overwhelming hotch potch of choices .. thanks for imposing some order on the chaos!

  • @skd181086
    @skd181086 2 роки тому

    Does JPA support pairwise comparison? If yes and if you have some video link for that kindly share

  • @mariavyxkyloves
    @mariavyxkyloves 4 роки тому

    done subscribe

  • @SergioTheDrifter
    @SergioTheDrifter 4 роки тому

    Is there a way to query a manytomany relationship ordering on a column in the join table?
    I have a nutrition database where Food and Nutrient are associated through Food_Nutrient and that has an amount field which I want to order by and then limit the results to 25 food entities.
    My last resort is native sql, but if I can do it otherwise I will.
    Thanks for the videos on the channel, they are very instructive.

  • @christophe_agoero
    @christophe_agoero 4 роки тому

    thank you for this video. You're not talking about request by specification. When to use them? Personally when my request is dynamic or without projection I use it. The advantage is that the specification is reusable unlike a criterion of the API criteria

  • @ashtwenty12
    @ashtwenty12 4 роки тому

    Excellent I was just looking for what best query to use for my project. thankyou. Ps is there a way I can query by eg a book object, when some of the values are not set and other times have all of different fields. criteria dto?