title: Call for understanding how the subclass entity is automatically mapped and saved
body: <p>I have 2 entities for now namely L100 and L218 as follows and both of them contains a Discriminator Value and  extends a Super Class entity ATUPosition which consists of the main @Table annotation as follows:</p>
  <p>L100</p>
  <pre><code>@Setter
  @Getter
  @Entity
  @EqualsAndHashCode(callSuper = true)
  @DiscriminatorValue(&quot;L100&quot;)
  public class L100 extends ATUPosition {
  
      @Column(name = &quot;pos_s_nocli_dos&quot;, length = 6)
      @CsvBindByPosition(position = 0)
      @Size(message = &quot;nocliDos cannot be greater than 6 characters&quot;, max = 6)
      private String nocliDos;
  
      @Column(name = &quot;pos_s_cocons&quot;, length = 1)
      @CsvBindByPosition(position = 1)
      @Size(message = &quot;cocons cannot be greater than 1 character&quot;, max = 1)
      private String cocons;
  
  // remaining columns below
  </code></pre>
  <p>L218</p>
  <pre><code>@Setter
  @Getter
  @Entity
  @EqualsAndHashCode(callSuper = true)
  @DiscriminatorValue(&quot;L218&quot;)
  public class L218 extends ATUPosition {
  
      @Column(name = &quot;pos_s_coste_nouv&quot;, length = 4)
      @CsvBindByPosition(position = 0)
      @Size(message = &quot;costeNouv cannot be greater than 4 characters&quot;, max = 4)
      private String costeNouv;
  
      @Column(name = &quot;pos_s_comonl_iso_rs&quot;, length = 3)
      @CsvBindByPosition(position = 1)
      @Size(message = &quot;comonlIsoRs cannot be greater than 3 characters&quot;, max = 3)
      private String comonlIsoRs;
  
  //remaining columns below
  
  </code></pre>
  <p>ATUPosition</p>
  <pre><code>@Entity
  @Table(name = &quot;Positions&quot;)
  @Inheritance(strategy=InheritanceType.SINGLE_TABLE)
  @DiscriminatorColumn(
          discriminatorType = DiscriminatorType.STRING,
          name = &quot;pos_s_type&quot;,
          length = 10
  )
  @AttributeOverride(name = &quot;uid&quot;, column = @Column(name = &quot;pos_n_id&quot;))
  @AttributeOverride(name = &quot;filename&quot;, column = @Column(name = &quot;pos_s_filename&quot;))
  @AttributeOverride(name = &quot;internalFilename&quot;, column = @Column(name = &quot;pos_s_int_filename&quot;))
  @AttributeOverride(name = &quot;fileDate&quot;, column = @Column(name = &quot;pos_d_filedate&quot;))
  @AttributeOverride(name = &quot;createdDate&quot;, column = @Column(name = &quot;pos_d_creation&quot;, nullable = false, updatable = false))
  @AttributeOverride(name = &quot;createdVisa&quot;, column = @Column(name = &quot;pos_s_created_visa&quot;, nullable = false))
  @AttributeOverride(name = &quot;lastModificationDate&quot;, column = @Column(name = &quot;pos_d_lastupdate&quot;, nullable = false))
  @AttributeOverride(name = &quot;lastModificationVisa&quot;, column = @Column(name = &quot;pos_s_lastupdate_visa&quot;, nullable = false))
  @Getter
  @Setter
  public abstract class ATUPosition extends AEntity {
      
      @Enumerated(EnumType.STRING)
      @Column(name = &quot;pos_s_position_state&quot;)
      protected PositionState positionState;
  
      @Enumerated(EnumType.STRING)
      @Column(name = &quot;pos_s_forex_extracted&quot;,length = 5)
      protected ExtractionState exchangeRateExtracted;
  </code></pre>
  <p>Now I have a method am calling to convert a CSV to these column values and the list returned is a list of ATUPosition. Below is the method:</p>
  <pre><code>  public List&lt;ATUPosition&gt; createCsvToBeanBuilderPositionDTO(@Nonnull File file,Class&lt;? extends ATUPosition&gt; clazz, String dto) throws IOException {
          log.info(&quot;Creating CSV for bean: {}&quot;, dto);
          return new CsvToBeanBuilder&lt;ATUPosition&gt;(new InputStreamReader(new FileInputStream(file)))
                  .withType(clazz)
                  .withFieldAsNull(CSVReaderNullFieldIndicator.EMPTY_QUOTES)
                  .withSeparator(Constants.DELIMITER[0])
                  .withIgnoreLeadingWhiteSpace(false)
                  .build()
                  .parse();
      }
  </code></pre>
  <p>After calling the method, I am able to save the entity as follows:</p>
  <pre><code>private long saveEntity(File file, Class&lt;? extends ATUPosition&gt; clazz, String csvFileName, String multiPartFileName) throws IOException {
          PositionConverter positionConverter = new PositionConverter();
          List&lt;ATUPosition&gt; listOfEntities = positionConverter.createCsvToBeanBuilderPositionDTO(file, clazz, csvFileName);
          long size = listOfEntities.stream()
                  .map(entity -&gt; {
                      entity.setFilename(FilenameUtils.getName(multiPartFileName));
                      entity.setInternalFilename(entity.getFilename());
                      entity.setCreatedVisa(&quot;AUTO&quot;);
                      entity.setLastModificationVisa(&quot;AUTO&quot;);
                      entity.setFileDate(FileUtils.extractLocalDateFromFilename(FilenameUtils.getBaseName(multiPartFileName)));
                      return entity;
                  })
                  .map(positionRepository::save)
                  .count();
          Files.deleteIfExists(file.toPath());
          return (int) size;
      }
  </code></pre>
  <p><strong>What I wish to understand is how is the CsvToBeanBuilder is able to return the specific entity am parsing depending on the Class attribute and how my PositionRepository below is able to save all the values such that my entity is a subclass of ATUPosition. My repo is as below:</strong></p>
  <pre><code>public interface PositionRepository&lt;T extends ATUPosition&gt; extends ATUPositionRepository&lt;T&gt; {
  
  }
  
  </code></pre>