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
0 answers

how can I add this child field to parentDTO?

I have this two entities entity Country { name String } entity Regions { name…
0
votes
1 answer

why in the json i get from jhipster dtos automatic generation give me null one to many relationship?

I generated DTOs with JHipster automatically. I didn't know how to see my json just with console and i get null in one to many relationship. This is what i get.[OperationDTO{id=1, date='2015-08-05T08:48:00Z', description='Mississippi Account…
0
votes
1 answer

How to I return a List of DTOs from my API controller

I have a class : public class Participant { [Key] public int ParticipantId { get; set; } [Column(TypeName ="nvarchar(50)")] public string Email { get; set; } [Column(TypeName = "nvarchar(50)")] public string Name { get;…
VenusMan
  • 17
  • 4
0
votes
0 answers

DTO having all string attributes in ASP.NET Core Web API

Assume you have the following model with navigation properties for EF Core public class Person { public Guid personId { get; set; } public Guid departmentId { get; set; } public string FirstName { get; set; } = null!; public…
user19187727
  • 169
  • 9
0
votes
2 answers

Lombok @Builder Model Class with field class and List Class

Im new to Spring and Im trying to create DTO with Lombok @Builder. But i having trouble set up the data from field class take a look at addressDTO and childsDTO in ParentDTO class. import java.util.List; import lombok.AllArgsConstructor; import…
SpicySandwich
  • 49
  • 1
  • 10
0
votes
1 answer

Is it possible to: Java DTO --> Swagger --> Java DTO?

In a very big Java app with lot's of DTOs, I want to export to an external project only the DTOs that are relevant to REST calls, and even better to export a part of them (the minimum required for REST calls). The project uses Swagger and I am…
Itai
  • 23
  • 4
0
votes
1 answer

Mapping multiple DTO to entities - nested exception

I'm trying to map DTOs to entities. I created a service that only takes care of mapping objects - ObjectMapper. DTO objects have relationships with each other. When I map a single object, for example when I create User, Group, Note, everything…
m_novak
  • 117
  • 10
0
votes
1 answer

Spring boot - How to convert DTO to entity that is part of another DTO

I have entities that represent my database - User, Recipe and Tag. For data manipulation I use DTO. So UserDTO, RecipeDTO, TagDTO. When I define a relationship between entities, I use its basic User, Recipe, Tag form, but when I define these…
m_novak
  • 117
  • 10
0
votes
1 answer

Serialize entity into DTO using SpringBoot and Lombok

I currently recieve a POST request with a JSON that is serialized into Cobranca entity by SpringBoot with lombrok getter and setter. I want to serialize this entity into a CobrancaDTO that latter will generate a second JSON with a different…
0
votes
0 answers

Problem with mapstruct java: Can't generate mapping method from iterable type to non-iterable type

I am new to java programming trying to do dto mapping,to implement data filtering @Data @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) public class Request { List eventType; String eventRef; List
0
votes
1 answer

GET method: How to convert snake_case query string to camelCase DTO

I use snake_case DB columns and camelCase DTO. And our team want to use snake_case when we code React component. Because of it, I added @JsonNaming on DTO. But it works when I send Json data, as you know. Is there any annotation or setting similar…
loveloper.dev
  • 299
  • 1
  • 4
  • 9
0
votes
2 answers

How to use @RequestParam with DTO

I have to make GET method with a DTO. But when I code like this↓, an error occurs. org.springframework.web.bind.MissingServletRequestParameterException: Required request parameter 'param' for method parameter type SampleDTO is not present After…
loveloper.dev
  • 299
  • 1
  • 4
  • 9
0
votes
1 answer

How to have few properties in Request Body as optional in Spring Boot

I have a REST endpoint(/users) in my controller which is of HTTP type POST, this REST endpoint accepts a RequestBody of users which has the following properties : { name: 'abc', address: 'xyz', phoneNo: '123', age: '12', email:…
nickgkd
  • 35
  • 7
0
votes
1 answer

How to implement conditional Validation in Nested DTOs - NestJS?

I am working in NestJS Project, there is one situation where I need to implement conditional Validation. So my Payload looks like this: { user_id: "123" user_type: "M" //Value Can be M or F inner_details: { name: { …
Akki
  • 1,718
  • 2
  • 29
  • 53
0
votes
0 answers

How to Map DTO class to "Model" class In generic Repository

I use DTO class in API layer and I struggle to map DTO class to "model" class in generic Repository.cs in core layer. Repository.cs : namespace DTOMap.Core.Repository.Generic { public class Repository : IRepository where T : class { …
antoine_d
  • 27
  • 4