How to Best Use Java Records as DTOs in Spring Boot 3

preview_player
Показать описание
Let’s look at a few approaches for using Java records as DTOs that apply to Spring Boot 3 with Hibernate 6 as the persistence provider and YugabyteDB as the database.

With the Spring 6 and Spring Boot 3 releases, Java 17+ became the baseline framework version. So now is a great time to start using compact Java Records as Data Transfer Objects (DTOs) for various database and API calls.

0:00 Intro
0:38 Application Overview
2:12 Java Records as DTOs: Naive Approach
4:05 Java Records as DTOs: TupleTransformer
6:10 Java Records as DTOs: Record Creation Within a JPA Query
8:13 Java Records as DTOs: Hypersistence Utils
10:47 Summary and Next Steps

About Yugabyte: YugabyteDB is an open source, high-performance distributed SQL database built for your mission-critical applications. It is PostgreSQL compatible, cloud native, and runs on any public or hybrid cloud.

RESOURCES:

COMMUNITY:

Рекомендации по теме
Комментарии
Автор

Great Video. I did not know about the IntegratorProvider. Thanks !

virajsh
Автор

Thank you for the tip. It is extremely helpful

ricardo-emerson
Автор

Thanks for that video, record implementation looks so clean that i don't even want to use mapstruct anymore 😅

RodrigoRocha-xd
Автор

I see you are using Vs code for spring boot application. How do you run multiple instance of an application in vs code when you are building an app using micro service architecture on Spring Boot?

Raj_Gada
Автор

thanks for this video, i was wondering how can i place the validation annotation and the validation groups

tkhyo
Автор

Hello, very good video but I have a question:

(suppose for another endpoint)
If we now want to get
the name of the track and its duration

We should create another query in which we only bring these two attributes.

I understand that this way it would be more performant, but we should have individual methods according to the data we want (since we have now 2 dtos), instead of having only one and mapping according to what we need.

Is there an intermediate solution or what would be the correct way to solve it? Thank you

PS: I used google to translate, sorry if what I wrote has errors

Esteban-ckqc
Автор

Sweet. Well explained. I am going to adopt this

vishnoor