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

MapStruct causes StackOverflowError

I'm stuck with mapping entity-> DTO. My model looks like : public class UserDto extends AbDto { private String login; private String firstName; private String lastName; private String position; private Set roles; } public class RoleDto…
Snopek1337
  • 13
  • 4
0
votes
0 answers

Can DataAnnotations break endpoints?

I work with a asp.net core (ABP) backend on daily basis, and many of our Dto's use DataAnnotation to require fields or limit inputs. These last days however, we've experienced that endpoints suddenly deny access from our angular frontend, which have…
Edunno
  • 91
  • 7
0
votes
1 answer

Swagger interface DTO in nestJs

export interface ProjectInterface { id: string; @ApiProperty title: string; description: string; How to use swagger docs implementation while using interface instead of class AS DTO? At API Property annotation error is showing because of…
0
votes
0 answers

How can I dynamically set certain properties null in c# using automapper

I have a list of objects in c#. And one object in the list contains 30 properties. I have another list of array which contains names of those property and it could be of any length say 10 or 20. My requirement is to assign null values to all those…
gorak
  • 1
  • 1
0
votes
0 answers

Unknown column 'whateverentity0_.end' in 'field list'

I have a Java project with MySQL database. I need to fetch entries from database and this is where I get the following error. Not sure why the end column is causing a problem. I checked several similar questions, but still can't see the solution in…
krltos
  • 313
  • 4
  • 20
0
votes
1 answer

Is using of dao when assembling entity to dto good way to use?

I have User entity that has relationship to other entities(Order,Profile) When I assemble entity from dto and back I need assemble order and profile entity too. User entity: @Table(name = "user_info") @Entity @Getter @Setter public class User…
DozezQuest
  • 179
  • 7
0
votes
0 answers

How can I prevent duplicate code when converting entity to dto using custom assembler(Without additional libraries)?

I have several entities but there are three entities that have relationship on each other(Car,CarCategory,Order) Car entity : @Entity @Table(name = "car_info") @Getter @Setter public class Car implements Serializable { private static final long…
DozezQuest
  • 179
  • 7
0
votes
1 answer

How to match an object consisting of other objects with Orika

I have three classes of entity(order,customer,sallers) and three classes of Dto. Me need to use Orika for mapping objects from entity classes to Dto. One of this(order) consist of data and links to another Dto objects. How i can map order entity to…
0
votes
0 answers

Do I need to use data transfer objects for deserialization of form input to an entity object using JPA?

I was wondering if it is possible to not use DTO and if there is any other approach, with JPA. Is it possible to create a new X object from the form input Y without first creating a DTO Z?
devo9191
  • 219
  • 3
  • 13
0
votes
1 answer

How can I add an additional json parent node when mapping a DTO?

I'm working on some data product mapping, and I stumbled across an issue I'm not sure how to solve. Suppose I have a HumanMood data product. I'm receiving pushed data (HumanMoodInputDto) through a POST request method received by WebFlux…
Airidas36
  • 21
  • 4
0
votes
2 answers

How to convert an Object to a custom DTO

Im having some issues trying to convert a List of Object to a custom DTO. However, all the answers that i found are focused on converting Entities or POJ0s to DTO. How can i do this in either some kind of iteration, or even manyally accesing all the…
0
votes
0 answers

How to create a customize primary constructor of sub data-class in Kotlin

I have a class structure like below: abstract class AuthorizeSalesRequestDto { open val sequenceNumber: Int = 0 open val currentService: String = "" open val amount: Int = 0 open val taxOthers: Int = 0 open val trainingMode:…
Dattq2303
  • 302
  • 2
  • 13
0
votes
1 answer

Using Dto vs Primitive when there's only one parameter

If there's only one parameter from the request (for example, memberId received for deleting), should I bind that parameter to Dto or just use it as a primitive? @DeleteMapping("/members/{memberId}") ResponseEntity deleteAccount(@PathVariable…
Roger
  • 7
  • 3
0
votes
1 answer

How do I pass "safe" data to the API correctly?

I started learning Node.js. And TypeScript. And very often I began to see work with DTOs. But for some reason people in their articles and documentation for frameworks do not give an example of working with user creation and encrypted password. I…
Colibri
  • 993
  • 11
  • 29
0
votes
1 answer

How do I test external DTO?

I want to test an external DTO that changes frequently. ex: I has a below javascript(json) file. // javascript const type User = { id: Number, name: String } // json user: { id: Number, name: String, } At this time, the external API…
Doho Kim
  • 3
  • 1