title: Parameter value [{}] did not match expected type [java.lang.String (n/a)]
body: <p>I'm getting the error "Parameter value [{}] did not match expected type [java.lang.String (n/a)]; nested exception is java.lang.IllegalArgumentException"</p>
  
  <p>Entity: </p>
  
  <pre><code>public class Job implements Serializable {
  
      @NotNull
      @Column(name = "args", nullable = false)
      private String args;
  
  
  
  </code></pre>
  
  <p>DTO : </p>
  
  <pre><code>public class JobDTO implements Serializable {
  
      @NotNull
      private JSONObject  args;
  
  </code></pre>
  
  <p>Repository : </p>
  
  <pre><code>@SuppressWarnings("unused")
  @Repository
  public interface JobRepository extends JpaRepository&lt;Job, Long&gt; {
  
      Job getByActionAndStatusAndCertificateInstanceIdAndAgentIdAndArgs(JobActions jobActions ,JobStatus jobStatus, Long certificateInstanceID, Long agentId, JSONObject args) ;
  
  }
  </code></pre>
  
  <p>service : </p>
  
  <pre><code>    /**
       * 
       * @param dayBeforeExpiration
       * @return
       */
      public List&lt;Certificate&gt; getExpiredCertificatesList(Long dayBeforeExpiration) {
          JSONObject args = new JSONObject(); 
          List&lt;Certificate&gt; certificates = extendedCertificateRepository.findExpiredCertificates(dayBeforeExpiration);
          for (Certificate certificate : certificates) {
              List&lt;CertificateInstance&gt; certificateInstances = extendedCertificateInstanceRepository
                      .findCertificateInstancesByCertId(certificate);
              for (CertificateInstance certificateInstance : certificateInstances) {
                  extendedCertificateRequestService.createJob(certificate.getAgent().getId(), certificateInstance.getId(),
                          JobActions.RENEW, args );
  
              }
          }
  
          return certificates;
      } 
  
  </code></pre>
  
  <pre><code>
      public JobDTO createJob(Long agentId, Long certificateInstanceId, JobActions action , JSONObject args ) {
  
          JobDTO jobDTO = new JobDTO();
          jobDTO.setAgentId(agentId);
          jobDTO.setCertificateInstanceId(certificateInstanceId);
          jobDTO.setAction(action);
          jobDTO.setStatus(JobStatus.PENDING);
          jobDTO.setArgs(args);
          return jobService.save(jobDTO);
  
      }
  
  
  
  </code></pre>
  
  <pre><code>     * @param jobDTO the entity to save
       * @return the persisted entity
       */
      public JobDTO save(JobDTO jobDTO) {
          log.debug("Request to save Job : {}", jobDTO);
          if(extendedJobService.ckeckIsRenewJobExist(jobDTO)){
              return jobMapper.toDto(jobRepository.getByActionAndStatusAndCertificateInstanceIdAndAgentIdAndArgs(jobDTO.getAction(), jobDTO.getStatus(), jobDTO.getCertificateInstanceId(),
                  jobDTO.getAgentId() , jobDTO.getArgs())) ;
          }
       Job job = jobMapper.toEntity(jobDTO);
         JobDTO result = jobMapper.toDto(job);
          jobSearchRepository.save(job);
          return result;
      }
  </code></pre>
  
  <p>JobMapper </p>
  
  <pre><code>@Mapper(componentModel = "spring", uses = {AgentMapper.class, CertificateInstanceMapper.class, ExtJobMapper.class})
  public interface JobMapper extends EntityMapper&lt;JobDTO, Job&gt; {
  
      @Mapping(source = "agent.id", target = "agentId")
      @Mapping(source = "certificateInstance.id", target = "certificateInstanceId")
      JobDTO toDto(Job job);
  
      @Mapping(source = "agentId", target = "agent")
      @Mapping(source = "certificateInstanceId", target = "certificateInstance")
      Job toEntity(JobDTO jobDTO);
  
  
  
      default Job fromId(Long id) {
          if (id == null) {
              return null;
          }
          Job job = new Job();
          job.setId(id);
          return job;
      }
  }
  
  </code></pre>
  
  <p>ExtJobMapper :to convert json object to string and inserts it</p>
  
  <pre><code>public interface ExtJobMapper {
  
  
      @Mapping(source = "org.json.JSONObject" , target ="java.lang.String")
      static java.lang.String mapJSONToString(org.json.JSONObject value) throws JsonProcessingException {
  
          ObjectMapper mapper = new ObjectMapper();
          String jsonString = mapper.writeValueAsString(value) ; 
  
          return jsonString ;
      }
  
      @Mapping(source = "java.lang.String" , target ="org.json.JSONObject")
      static  org.json.JSONObject mapStringToJson(java.lang.String value) throws JsonProcessingException {
  
          JSONObject convertedObject = new Gson().fromJson(value, JSONObject.class);
  
  
          return convertedObject ;
      }
  
  }
  
  </code></pre>
  
  <p>edit JobService 
  The args object is implicitly converted to the String value by calling the toString method but the same problem </p>
  
  <pre><code>    public JobDTO save(JobDTO jobDTO) {
          log.debug("Request to save Job : {}", jobDTO);
          if(extendedJobService.ckeckIsRenewJobExist(jobDTO)){
              return jobMapper.toDto(jobRepository.getByActionAndStatusAndCertificateInstanceIdAndAgentIdAndArgs(jobDTO.getAction(), jobDTO.getStatus(), jobDTO.getCertificateInstanceId(),
                  jobDTO.getAgentId() , jobDTO.getArgs())) ;
          }
          Job job = new Job(jobDTO.getAction(),jobDTO.getArgs().toString(),jobDTO.getStatus(), agentRepository.getOne(jobDTO.getAgentId()), certificateInstanceRepository.getOne(jobDTO.getCertificateInstanceId())) ;
          job = jobRepository.save(job);
  
          JobDTO result = new JobDTO(job.getAction(), new JSONObject(job.getArgs()),job.getStatus(), job.getAgent().getId(),
          job.getCertificateInstance().getId()) ;
          jobSearchRepository.save(job);
          return result;
      }
  
  </code></pre>