Questions tagged [dto]

DTO is an acronym for Data Transfer Object, a design pattern used in data transfer.

DTO is an acronym for Data Transfer Object, a design pattern used in transferring data through internal or external interfaces. A DTO protects the application's internal data by acting as dummy storages, the whole logic is implemented only in actual Domain Objects (DO).

Pros:

  • Fewer remote calls (typically one, getDto() vs. individual getId(), getName(), etc.)
  • Improved data capsulation (Remote systems need only to know the details of the DTO, not DO internals)

Cons:

  • class explosion
  • conversions needed between DTOs and DOs
2100 questions
0
votes
1 answer

ModelMapper to inner class mapping

I'm trying to map a JPA Entity to a DTO, which has an inner object. I want to map a specific field in the super class of the entity, to a field in the inner object of that DTO. Let's see as example the User DB Entity, and the…
Rohi
  • 385
  • 6
  • 22
0
votes
1 answer

Dto map and use-case

how can I make Dto map and pass it to the use-case using clean architecture in android kotlin i tried to make an object class and pass it to the use-case but it didn't work
0
votes
2 answers

Retrieve JSON Array or JSON Object using JPA Projections & DTO interface

I have a DTO interface which fetches data from different tables using joins. I have made a DTO interface with the abstract getter methods something like this. public interface HRJobsDTO { String getEditorName(); String getEditorId(); …
0
votes
3 answers

Convert for each loops to stream

I try to convert some for each loops to streams. I have following object relations: the main object is a collection of sensors each sensor has commands and attributes objects each command object has members objects each attribute object has fields…
vag
  • 3
  • 1
0
votes
1 answer

Should I use different DTO for Create and Update?

I have create and update operation for user and the following UserDto public class UserDto { @NotBlank private String username; @NotBlank private String password; @NotBlank private String mobileNo; ... other variables, etc. } For…
Muse
  • 1
  • 2
0
votes
0 answers

MapStruct DTO->Entity mapping with OneToMany as FK in DTO

Hi I'm pretty new to Java and Spring Boot. I have an API which uses 3 entities: @Entity public class Account { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(updatable = false, nullable = false) int id; //…
aFku
  • 37
  • 2
  • 7
0
votes
0 answers

NestJS: How to validate a payload field based on another payload field?

would like to know if it is possible to validate a field based on the datatype of another field? My requirement is like this: payload: { fieldName: "firstName", filter: "CONTAINS", value: "axe" } I need to create a custom decorator/validator to…
astra.xvi
  • 43
  • 7
0
votes
1 answer

Return inherited DTO from API controller along with parent fields to the client

I have a parent DTO as following: public abstract class BaseDTO { public list message = new list(); } and a child class: public class MyDTO : BaseDTO { public string name { get; set; } } now when I try to view MyDTO in…
Behnam Faghih
  • 164
  • 1
  • 17
0
votes
2 answers

Conversion between DTO and Entity using Interface

Is it ok to use an Interace for converting between DTO and Entity? public interface UserDto { public long getId(); public String getName(); public String getEmail(); public String getPassword(); } public interface UserEntity extends…
0
votes
0 answers

Correct endpoint and DTO structure

Imagine I have the next two entities public int Id {get;set;} public string Desc {get;set;} public int AssignmentId {get;set;} public Assignment Assignment {get;set;} class Assignment{ public int Id {get; set;} public ICollection Tasks…
Bookuha
  • 13
  • 5
0
votes
1 answer

How to get JSON List of string from column of mysql table using custom Dto query

i want to query a list from specific column of table using dto, my actual query is so complex containing 3 joins, i have added dummy code for the problem statement. and i'm facing this…
pradeexsu
  • 1,029
  • 1
  • 10
  • 27
0
votes
0 answers

How to use a DTO class passing a Embedded class for verification?

How can I tackle a @Embedded class inside of a Model class? I'm trying to use a DTO to filter and check the requests being sent to the POST mapping. I want to check, let's say, if the fullName is not blank. (request body…
guilhermxlopes
  • 138
  • 1
  • 7
0
votes
0 answers

Spring, DTO or Entity

I have provided an image from the video https://www.youtube.com/watch?v=SG2gfTPzSQE for which i would like to implement this flow My question is, if i was applying business logic in the layer labelled as "Service" should I use database entities ?…
user12383896
0
votes
1 answer

How to mutate a one-to-many relationship using EF Core and Dto's?

How to mutate a one-to-many relationship using EF Core and Dto's? I'm trying to edit a list of trainees by adding / removing a user using DTO's and EF-core. So far adding a user to the list persists but not the removal. What am I missing? Thank you…
Dama
  • 1
  • 2
0
votes
0 answers

NestJS: DTO validation does not work with formdata

My problem is the following: I am making a request which contains data and images, so the data is sent through formData. The DTO does not validate the fields when they are sent in this way, I get response messages as if these fields did not exist,…
Alex
  • 671
  • 5
  • 19