DTO
Can anyone help me to create DTO for this classes and also explain me why we use DTO more
8 Replies
⌛
This post has been reserved for your question.
Hey @Danix! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
Assuming you are using a recent Java and Spring version, you can just use records as DTOs:
Like these would be the DTO classes
These are methods right so what to do with them ?
classes
If you want to (de)serialize your dara from/to JSON, you would use DTOs
that allows you to have a JSON data format that deviates from your internal storage
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
Ok so I have to use DTO when I have to convert my entities to json format right but if I have to register the user from a form then should I have to use a DTO or make it simple ?
It depends. DTOs can even be useful with forms
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.