title: JPQL Query - No constructor taking error?
body: <p>I have a Card entity class with many columns.
  I used dto because I want to get some columns from this Entity.
  I created a DTO class and wrote a query to CardRepositoryCustom.
  But when I try to run the Query I get various errors &quot;No constructor taking&quot;.</p>
  <p>My dto class:</p>
  <pre><code>@Data
  @NoArgsConstructor
  @AllArgsConstructor
  public class CardDTO {
      private String test1;
      private String test2;
      private String test3;
      private String test4;
  }
  </code></pre>
  <p>JPQL RepositoryCustom :</p>
  <pre><code>@Repository
  @Transactional
  public class CardRepositoryCustom {
  
      public CardDTO test1() {
          JpaResultMapper jpaResultMapper = new JpaResultMapper();
          String q =  &quot;SELECT          &quot;+
                      &quot;   c.test1  &quot;+
                      &quot;FROM            &quot;+
                      &quot;   CardEntity c &quot;;
          Query query = entityManager.createQuery(q);
          try {
              return jpaResultMapper.uniqueResult(query, CardDTO.class);
          } catch (NoResultException nre) {
              return null;
          }
      }
  }
  </code></pre>
  <p>Errors:</p>
  <pre><code>java.lang.RuntimeException: No constructor taking: java.lang.String
  at org.qlrm.mapper.JpaResultMapper.findConstructor(JpaResultMapper.java:107) ~[qlrm-1.7.1.jar:na]
      at org.qlrm.mapper.JpaResultMapper.uniqueResult(JpaResultMapper.java:64) ~[qlrm-1.7.1.jar:na]
      at ....
  </code></pre>
  <p>I know how to fix this error.
  You just need to write the following constructor in the DTO class as shown below.</p>
  <pre><code>public CardDTO(String test1) {
      this.setTest1(test1);       
  }
  </code></pre>
  <p>Here I am curious, if I want test2, test3, test4 and write Query in Custom class, should there be as many constructors in DTO class as that number?</p>
  <p>I think this method is really inefficient. Is there any solution I am not aware of?</p>