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

Return DTOs in the controller

I have an Operation service that has a list function that returns a list of OperationDTO however when the controller calls this function the list returns null dto objects and if I change the type of return in the service to Operation entity type the…
khazim
  • 11
  • 4
0
votes
1 answer

Extracting data from DDD Entity/Aggregate

Can someone please clarify the following topic? I haven't found enough complex answer to this, just some basic examples of how this should work, so I am asking here. Let's say we have an entity Invoice. The Invoice has some private props like date…
Daniel Vítek
  • 185
  • 12
0
votes
2 answers

Spring Boot Entity to DTO ConverterNotFoundException

I have a simple API, built with Spring Boot, where I am trying to convert entity classes to the corresponding dtos. Student Entity @Entity(name = "students") @AllArgsConstructor @Getter @Setter public class Student extends AbstractUpdatable
0
votes
1 answer

How to add 4 DTO in one cshtml?

i have 4 dto and i want to use it in cshtml. How do I call those 4 dto? tbCUserGuideSlugfContent,tbCUserGuideSlugDTO,fImageJSONResDTO,fImageJSONDTO tbCUserGuideSlugfContent public class tbCUserGuideSlugDTO { public Nullable
user18286751
0
votes
0 answers

Create class with same fields as another class with few exceptions

Suppose I have class A like this class A { private String Id; private String name; private String age; //... some other hundres of feilds } How can I create another DTO named CreateA which contains all fields for A except the one I…
너를 속였다
  • 899
  • 11
  • 26
0
votes
1 answer

Use DTO to map JSON to final object, or just parse JSON?

I have some json object that looks like this: { "make":"Volvo", "model":"240", "metadata":{ "color":"white", "year":"1986", "previousOwner":"Joe", "condition":"good" } } And I want to turn this JSON into…
N.A
  • 135
  • 1
  • 6
  • 13
0
votes
3 answers

4 DTOs by default for Spring REST API?

hello, I've been looking for something related for a few weeks, but I'm not convinced. I'm making a RestAPI. And, I know about the DTO. First, look at the picture above. The red picture is the part I drew. Except for the red part, DTO is only…
바보린
  • 159
  • 1
  • 13
0
votes
2 answers

Problems with column duplication when designing a Spring Restful DTO

I am learning about DTO recently. Among them, Request DTO can be created in various ways. As an example, we will take two examples of create and update related to User. To create a user Let's say it takes name, sex, age, phoneNumber. Then my…
바보린
  • 159
  • 1
  • 13
0
votes
1 answer

how to get name value associated with integer in dto

i'm using java, for example, i have 2 tables staff(id, name, status_id, company_id) and company(id, name), the corresponding entity looks like: public class Staff { private Integer id; private String name; private Integer statusId; …
frank
  • 1,169
  • 18
  • 43
0
votes
1 answer

How to get value from list that is in another list which in another list

I have a Dto class with variables which one of them is another class. and inside another class there is a variable List with another class. public class GetList { private String id; private ResultGetList result; } public class…
0
votes
0 answers

Mapstruct: Mapping a dto in a dto to an entity in an entity

Mapstruct is not using a mapper declared in the "uses" definition in the @Mapper Annotation I expected the productCategory and productPrices to be mapped by the mappers: ProductPricesMapper.class, ProductCategoryMapper.class that are declared below…
0
votes
1 answer

Why do we have to convert entity to dto?

I'm trying to understand Spring Boot and building Rest APIs. I've seen some projects which is creates their own Converter class or which is using modelMapper. But I couldn't clearly get the main idea. Why do we have to convert entities to DTOs? I…
eagerdev
  • 83
  • 1
  • 6
0
votes
2 answers

Map several fields to List with a mapstruct

for example, I have following entity: class Bank { String name; String employee1; String employee2; } And a Dto object: class BankDto { String name; List employeeList; } Is there a proper way how to map Bank to BankDto, so employee1 and…
Andrey
  • 35
  • 4
0
votes
0 answers

JUnit - Service Layer - DTO - Error: Argument(s) are different

I send the Object as a DTO to the Service Layer Here it is concerted to Entity and sent to the DAO Layer: Service Layer: @Override @Transactional public void addUser(StudentDto newStudentDto) { …
Filippo
  • 11
  • 4
0
votes
0 answers

Error when I try to convert Json String to Object DTO in Java

I am trying to convert a JSON to a disc that I already have implemented in my code and in this way be able to access the values of the properties with which the disc will remain to build a logic in another part of my code, thank you your help as i…