title: Design of multiple child dtos into a single request spring boot
body: <p>So, I have a VehicleDto:</p>
  
  <pre><code>class VehicleDto {
      private String someId
      private String vType;
      private CarDto car;
      private BikeDto bike;
  }
  </code></pre>
  
  <p>I need to have either the CarDto or BikeDto in the request payload. </p>
  
  <p>In the post request payload there will be multiple fields which are properties of VehicleDto, for example, here someId. Now, this someId is also a part of CarDto and BikeDto, and any other Dto that is a child of VehicleDto. </p>
  
  <p>So when I try to save into the db, I have some issues there. </p>
  
  <pre><code>if (vehicleDto.getVType().equals("CAR")) {
      this.saveCar(vehicleDto);
  }
  
  private boolean saveCar(TicketSoldCreateDto ticketSoldCreateDto) {
      CarDto carDto = ticketSoldCreateDto.getCar();
      carDto is mapped to Car model
      // Now how do I map the rest of the fields in vehicleDto to Car model??
  }
  </code></pre>
  
  <p>Super class Vehicle:</p>
  
  <pre><code>@MappedSuperclass
  @Data
  public abstract class Vehicle extends AbstractBaseEntity {
  // fields same as vehicleDto
  }
  </code></pre>
  
  <p>Child class Car:</p>
  
  <pre><code>@Entity
  @Data
  public class Car extends Vehicle {
  // Some fields
  }
  </code></pre>
  
  <p>How should I design such problems?</p>