title: JPA query: java.lang.IllegalArgumentException: At least 1 parameter(s) provided but only 0 parameter(s) present in query
body: <p>The exception is thrown when I want to query for the youngest (by date) record by userId with userId not empty.. Is this method written correct or there is some error ?</p>
  
  <p>I have following components:</p>
  
  <p><strong>Repository</strong></p>
  
  <pre><code>public interface CustomEventStorage extends JpaRepository&lt;CustomEventData, CustomEventDataId&gt; {
      CustomEventData findFirstByUserIdNotNullOrderByIdDateDesc(@Param("userId") String userId);
  }
  </code></pre>
  
  <p><strong>Entity</strong></p>
  
  <pre><code>@Entity
  @Table(name = "event")
  public class CustomEventData {
  
      @EmbeddedId
      private CustomEventDataId id;
  
      @Column(name = "state")
      @Enumerated(EnumType.STRING)
      private EventState state;
      @Column(name = "user_id")
      private String userId;
  </code></pre>
  
  <p><strong>Embedabble id</strong></p>
  
  <pre><code>@Embeddable
  public class CustomEventDataId implements Serializable {
  
      @Column(name = "event_id")
      private String eventId;
      @Column(name = "date")
      private LocalDateTime date;
  </code></pre>
  
  <p><strong>Exception</strong></p>
  
  <blockquote>
    <p>Caused by: java.lang.IllegalArgumentException: At least 1 parameter(s)
    provided but only 0 parameter(s) present in query.
        at org.springframework.util.Assert.isTrue(Assert.java:136) ~[spring-core-5.1.7.RELEASE.jar:5.1.7.RELEASE]
        at org.springframework.data.jpa.repository.query.QueryParameterSetterFactory$CriteriaQueryParameterSetterFactory.create(QueryParameterSetterFactory.java:291)
    ~[spring-data-jpa-2.1.8.RELEASE.jar:2.1.8.RELEASE]
        at org.springframework.data.jpa.repository.query.ParameterBinderFactory.lambda$createQueryParameterSetter$1(ParameterBinderFactory.java:139)
    ~[spring-data-jpa-2.1.8.RELEASE.jar:2.1.8.RELEASE]
        at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
    ~[na:1.8.0_242]
        at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
    ~[na:1.8.0_242]
        at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
    ~[na:1.8.0_242]
        at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:499)
    ~[na:1.8.0_242]
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:486)
    ~[na:1.8.0_242]
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
    ~[na:1.8.0_242]
        at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
    ~[na:1.8.0_242]
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    ~[na:1.8.0_242]
        at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:531)
    ~[na:1.8.0_242]
        at org.springframework.data.jpa.repository.query.ParameterBinderFactory.createQueryParameterSetter(ParameterBinderFactory.java:141)
    ~[spring-data-jpa-2.1.8.RELEASE.jar:2.1.8.RELEASE]
        at org.springframework.data.jpa.repository.query.ParameterBinderFactory.lambda$createSetters$0(ParameterBinderFactory.java:131)
    ~[spring-data-jpa-2.1.8.RELEASE.jar:2.1.8.RELEASE]
        at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
    ~[na:1.8.0_242]
        at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
    ~[na:1.8.0_242]
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
    ~[na:1.8.0_242]
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
    ~[na:1.8.0_242]
        at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
    ~[na:1.8.0_242]
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    ~[na:1.8.0_242]
        at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:566)
    ~[na:1.8.0_242]
        at org.springframework.data.jpa.repository.query.ParameterBinderFactory.createSetters(ParameterBinderFactory.java:132)
    ~[spring-data-jpa-2.1.8.RELEASE.jar:2.1.8.RELEASE]
        at org.springframework.data.jpa.repository.query.ParameterBinderFactory.createSetters(ParameterBinderFactory.java:124)
    ~[spring-data-jpa-2.1.8.RELEASE.jar:2.1.8.RELEASE]
        at org.springframework.data.jpa.repository.query.ParameterBinderFactory.createCriteriaBinder(ParameterBinderFactory.java:75)
    ~[spring-data-jpa-2.1.8.RELEASE.jar:2.1.8.RELEASE]
        at org.springframework.data.jpa.repository.query.PartTreeJpaQuery$QueryPreparer.getBinder(PartTreeJpaQuery.java:250)
    ~[spring-data-jpa-2.1.8.RELEASE.jar:2.1.8.RELEASE]
        at org.springframework.data.jpa.repository.query.PartTreeJpaQuery$QueryPreparer.(PartTreeJpaQuery.java:149)
    ~[spring-data-jpa-2.1.8.RELEASE.jar:2.1.8.RELEASE]
        at org.springframework.data.jpa.repository.query.PartTreeJpaQuery$CountQueryPreparer.(PartTreeJpaQuery.java:270)
    ~[spring-data-jpa-2.1.8.RELEASE.jar:2.1.8.RELEASE]
        at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.(PartTreeJpaQuery.java:79)
    ~[spring-data-jpa-2.1.8.RELEASE.jar:2.1.8.RELEASE]
        ... 70 common frames omitted</p>
  </blockquote>