5 Java Libraries You Should Know

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

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

  • @salithachathuranga6037
    @salithachathuranga6037 10 месяцев назад +1

    Lombok library provides record builder functionality. It is way more used in the industry in enterprise level.

    • @sivalabs
      @sivalabs  10 месяцев назад

      Yes, Lombok is a widely used library and I too have used it extensively (www.sivalabs.in/should-you-use-lombok-or-is-it-bad-for-you/). I never had any trouble while using Lombok alone, but when used it with other annotation processors like MapStruct, AutoValue then there are some issues.

  • @rameshj9198
    @rameshj9198 8 месяцев назад +1

    Thank you for sharing these helpful libraries.

  • @Anbu_Sampath
    @Anbu_Sampath 10 месяцев назад +1

    RecordBuilder seems interesting library.

  • @cesar.vasconcelos
    @cesar.vasconcelos Месяц назад

    Hi Siva. I have seen your IntelliJ Session hosted by Mala Gupta (very, very good presentation by the way) and there you have used Spring Projections to create Dtos, instead of using MapStruct. Would you still recommend Spring Projections instead of MapStruct on enterprise applications development? Thanks for the video.

    • @sivalabs
      @sivalabs  Месяц назад +1

      By using Spring Projection you can load only the columns you need. But using MapStruct you load entire entity first and then map the required properties to a DTO. This may result in loading unnecessary data.
      So, I would recommend to use either interface-based projections or class-based projections to load only the required data from database. An important thing to consider is, we can't load nested objects while using class-based projections, but it is possible with interface-based projections.

    • @cesar.vasconcelos
      @cesar.vasconcelos Месяц назад

      @@sivalabsThank you very much, Siva, for this explanation.

  • @ratikantapradhan1537
    @ratikantapradhan1537 9 месяцев назад

    Regarding MapStuct, does it support expression/ conditional kind of conversion?
    Like suppose, I have a wrapper class Boolean in Entity. But I want to pass primitive boolean to DTO. Expression will be
    flag == null ? false : true
    flag is wrapper Boolean class in Entity.

    • @sivalabs
      @sivalabs  9 месяцев назад +1

      Yes, it checks for null and assign the correct value as follows:
      boolean active = false;
      if ( user.active() != null ) {
      active = user.active();
      }
      UserDTO userDTO = new UserDTO( id, fullName, emailAddress, active );