title: How can i pass an string parameter to custom repository method?
body: <p>I have a problem with AJAX + Rest + Spring boot + MySQL. Request is sucess but response is empty, no matter the format used in the request. In fact, the request payload shows ["customer" : "MyCustomer"] so problem is in controller, i think.</p>
  
  <p>AJAX
  function ajax_ciudad(customer) {      // onchange en select box</p>
  
  <pre><code>$.ajax({
      type: "POST",
      contentType: "application/json",
      url: "/api/ciudades",
      data: JSON.stringify(customer),
      dataType: 'json',
      cache: false,
      timeout: 600000,
          }).then(function(data) {
              DO SOMETHING.... 
             });
          });
  </code></pre>
  
  <p>}</p>
  
  <p>CONTROLLER</p>
  
  <pre><code>@RestController
  @RequestMapping
  public class SearchController {
  @Autowired
      private MyRepository myRepository;
      @PostMapping("/api/ciudades")
      public @ResponseBody List&lt;?&gt; getSedes(String customer){
  
          List&lt;Canal&gt; ciudades = myRepository.findBySede(customer);
          return ciudades;
      }
  
  
  REPOSITORY
      @Query(value ="SELECT * FROM canal WHERE cliente = ?1", nativeQuery = true)
      List&lt;Canal&gt; findBySede(@Param("customer") String customer);
  </code></pre>
  
  <p>... Always return an empty object []</p>
  
  <p><a href="https://i.stack.imgur.com/F6QkZ.png" rel="nofollow noreferrer">enter image description here</a></p>
  
  <p>I have tried several formats for data, i tried getting the Select value using .val() to get the String, using .value to get the html value.... If i put manually a parameter like myRepository.findBySede("MyString") the ajax response has info, but when i pass the value it doesn't work; What i'm doing wrong? Thanks for your help</p>
  
  <p>My entity class</p>
  
  <pre><code>@Entity
  @Table(name = "canal")
  public class Canal { 
  
      @Id
      @GeneratedValue(strategy=GenerationType.IDENTITY)
      @Column(name = "idcanal", unique = true, nullable = false)
      int id;
      @Column(name = "cliente")
      String cliente;
      @Column(name = "ciudad")
      String ciudad;
      @Column(name = "sede")
      String sede;
      @Column(name = "canal")
      String canal;
      @Column(name = "ip_pe")
      String ip_pe;
      @Column(name = "nombre_pe")
      String nombre_pe;
      @Column(name = "ipwan_pe")
      String ipwan_pe;
      @Column(name = "puerto_pe")
      String puerto_pe    ;
      @Column(name = "ipwan_router")
      String ipwan_router;
      @Column(name = "enrutamiento")
      String enrutamiento;
      *****getters and setters****
       }
  </code></pre>