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

Creating Laravel DTO from request with optional fields

I'm using Spatie Laravel-data to create data objects to pass in and out of an API. I'm hitting an issue trying to create a DTO from a POST request - there are certain fields that won't be passed in for an INSERT, the obvious one being ID. I'm…
charliefortune
  • 3,072
  • 5
  • 28
  • 48
0
votes
0 answers

How can I map data to a CSV file to find 4 values looping?

How can I map the data to four values for the BalanceDTO instead of two like in the example I made for the NetDTO. Any help will be appreciated, I want to find the 4 values to map them. I just need help in the loop to find the values. Thanks in…
0
votes
1 answer

Is it recommended to insert data into a database through a DTO or DTO is supposed to be read data from the Database only?

I am confused as to the actual usage of a DTO, and my confusion arises from the fact that most articles say that DTOs are to be used to read data from database and pass it to external clients and then these external clients will then choose to do…
Obert
  • 3
  • 2
0
votes
1 answer

NestJS : ERROR [ExceptionHandler] Nest can't resolve dependencies of the ClientService

I am working with NestJSproject. I make an entity Client and a DTO for the "inscrit()" function when I ran the project, I got the following: ERROR [ExceptionHandler] Nest can't resolve dependencies of the ClientService (?). Please make sure that the…
0
votes
1 answer

c# converting object using DTOs

Good day, I have these classes I populate from db: public class BaseProduct { public int Id { get; set; } public string Name { get; set; } public string Description { get; set; } public int MainCategoryId { get;…
0
votes
1 answer

Is there any way to use one value from retrieved List in HQL?

I am trying to map an Entity to respective DTO list using HQL. Is there any way to select only the first element of an URL list and the latest date element from a Map? Here is the query I am trying to build: @Query("SELECT NEW…
Lorena
  • 21
  • 5
0
votes
0 answers

Spring boot: composite key fails when trying the add method

I have a spring boot app which is basically the backend of a simple e-commerce site. There are four entities: product, order, customer and orderproduct. The last one has a composite key, made from the respective order and product entities. They have…
0
votes
1 answer

I wan't to create unit test that handle an exeption when dto fields != entity fields

I want to create unit test that handle an exception when dto fields != entity fields. And print missing and extra fields. Is it possible to make it with MapStruct? Simple example without annotations and boilerplate code. I have public class TestDto…
Taras
  • 106
  • 6
0
votes
2 answers

How should I pass the author of the change into PUT/POST methods?

I have a Category class which looks like this: public class Category { [Required] public Guid Id { get; set; } [Required] public string CategoryName { get; set; } public string CategoryDescription { get; set; } public…
Palamar66
  • 212
  • 1
  • 9
0
votes
0 answers

I have a problem that "@IsNotEmpty" in Dto does not check empty

I am building a project using NestJs. I have a problem that "@IsNotEmpty" in Dto does not check empty. The checking is only performed because {require: true} in the schema. Please help me with this case. Thank you! Here is my code: import {…
0
votes
1 answer

How to extends from data class in kotlin?

I want to create data class extend from another data class. I can not extend from another data class because of another data class is data class and i have no chance that change another data class. Another data class must be data class (not…
feyfhe
  • 3
  • 1
0
votes
0 answers

Junit Test got error NestedServletException when try to excute Junit Test for RestApi DeleteById

org.springframework.web.util.NestedServletException: Request processing failed Get this exception error when try to execute Junit Test for restApi method to DeleteById the problem that in Controller implements when i change return type of method…
MR Int
  • 1
  • 2
0
votes
2 answers

Nested Linq in c#

I want to extract a list using linq as tree structure. { "details": [ { "description":"This is description 1", "Name": "Name 1" }, { "description":"This is description 2", …
0
votes
3 answers

Business Object to DTO conversion

I have a list of types of application. I want to transform that object to an object of type ApplicationDTO. Inside that Application business object, there is a list of Applicants of the type Applicant. Now my DTO has the same list but I am…
Florent
  • 111
  • 10
0
votes
0 answers

ModelMapper: How to map a field to its object type using service layer methods

I have Employee class @Data public class Employee { private Integer id; private String firstname; private String lastname; private String email; private String code; private Integer managerEmployeeId; private Integer…
GenZ Dev
  • 210
  • 4
  • 16