JPA & Hibernate - Why, When & How to use DTO Projections

Поделиться
HTML-код
  • Опубликовано: 19 окт 2024

Комментарии • 14

  • @Serhiy-Nechosov
    @Serhiy-Nechosov 3 года назад +2

    Good day, everyone!!! Thank you very much, very needed information

  • @Quester82
    @Quester82 2 года назад +3

    Is there an out of the box way to create such a projection with nested fields like, for example, List items; ?
    And if here is no way to do that what do you suggest to do when you actually need to build such a projection?

  • @TimoSurfs
    @TimoSurfs 3 года назад

    Incredibly helpful video!

  • @rahulkhimasia
    @rahulkhimasia 3 года назад

    Very informative. Thanks.

  • @robertzdeb8103
    @robertzdeb8103 3 года назад

    Great stuff!

  • @ajayuyyala338
    @ajayuyyala338 3 года назад

    Much needed information. Do they support nested DTO projection? Like objects with collection objects.

    • @Thorben-Janssen
      @Thorben-Janssen  3 года назад +2

      Hi Ajay,
      No, there is no support for nested DTO projections.
      You could add a constructor to your top-level class and instantiate the nested DTO objects in there. But please keep in mind that Hibernate applies the constructor to each record in the result set as the database returns it. This result set is a flat data structure. You can't access the full list of a to-many association in the constructor because the database returns it as author1-book1, author1-book2, author1-book3, ...

    • @ajayuyyala338
      @ajayuyyala338 3 года назад

      @@Thorben-Janssen thank you for the reply. Yes the result set is a flat data structure. My response format is a bit complex. I used the constructor to create a temporary response and converted it to my desired response format using mapstruct.
      Your blog has been very much useful. Thank you!

  • @MrMikomi
    @MrMikomi 3 года назад +1

    Hi, how can we verify that Dto projections are more performative than eg entity projections? Thanks.

  • @shubhamchauduary4492
    @shubhamchauduary4492 2 года назад

    @ThorbenJanssen How to use the nested DTO data Projection

  • @ganeshvbidwe
    @ganeshvbidwe 3 года назад

    Hello Thorben Janssen,
    Please provide the entire source code

  • @tgf972
    @tgf972 3 года назад

    sympathisch

  • @richJinny
    @richJinny 3 года назад

    The Criteria API is awfull!