title: java.lang.IllegalArgumentException: Could not locate named parameter [user], expecting one of [min, gender, max]
body: <p>I get </p>
  
  <pre><code> INFO 4508 --- [nio-8081-exec-9]  j.r.q.QueryParameterSetter$ErrorHandling : Silently ignoring
  
  java.lang.IllegalArgumentException: Could not locate named parameter [user], expecting one of [min, gender, max]
      at org.hibernate.query.internal.ParameterMetadataImpl.getNamedParameterDescriptor(ParameterMetadataImpl.java:218) ~[hibernate-core-5.3.10.Final.jar:5.3.10.Final]
      at org.hibernate.query.internal.ParameterMetadataImpl.getQueryParameter(ParameterMetadataImpl.java:187) ~[hibernate-core-5.3.10.Final.jar:5.3.10.Final]
      at org.hibernate.query.internal.QueryParameterBindingsImpl.getBinding(QueryParameterBindingsImpl.java:188) ~[hibernate-core-5.3.10.Final.jar:5.3.10.Final]
      at org.hibernate.query.internal.AbstractProducedQuery.setParameter(AbstractProducedQuery.java:493) ~[hibernate-core-5.3.10.Final.jar:5.3.10.Final]
      at org.hibernate.query.internal.AbstractProducedQuery.setParameter(AbstractProducedQuery.java:106) ~[hibernate-core-5.3.10.Final.jar:5.3.10.Final]
      at org.springframework.data.jpa.repository.query.QueryParameterSetter$NamedOrIndexedQueryParameterSetter.lambda$setParameter$4(QueryParameterSetter.java:113) [spring-data-jpa-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.data.jpa.repository.query.QueryParameterSetter$ErrorHandling$2.execute(QueryParameterSetter.java:185) ~[spring-data-jpa-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.data.jpa.repository.query.QueryParameterSetter$NamedOrIndexedQueryParameterSetter.setParameter(QueryParameterSetter.java:113) [spring-data-jpa-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.data.jpa.repository.query.ParameterBinder.lambda$bind$0(ParameterBinder.java:79) [spring-data-jpa-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at java.util.ArrayList.forEach(ArrayList.java:1257) ~[na:1.8.0_231]
      at java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1082) ~[na:1.8.0_231]
  </code></pre>
  
  <p>Code</p>
  
  <pre><code>    @Repository
      public interface UserRepo extends JpaRepository&lt;User, Long&gt; {
        @Query("select new com.newcode.meeting.domain.dto.UserDto( " +
          " us, " +
          " SUM (case  when ul.userLike = :user then 1 else 0 end) &gt; 0  " +
          ") from User us left join us.likes ul  where " +
          " us.birthDate BETWEEN :max and  :min " +
          " and  us.gender =:gender group by us ")
  Page&lt;UserDto&gt; findUsersByBirthDateIsBetweenAndGenderDto(
          Pageable pageable,
          @Param("max") LocalDate max,
          @Param("min") LocalDate min,
          @Param("gender") Gender gender,
          @Param("user") User user
  );
  </code></pre>
  
  <p>Class UserDto if you need someone to see.
  I do not know what else to add so that it does not write -"looks like your post is mostly code; please add some more details."</p>
  
  <pre><code> import com.fasterxml.jackson.annotation.JsonView;
   import com.newcode.meeting.domain.Image;
   import com.newcode.meeting.domain.ProfileDetail;
   import com.newcode.meeting.domain.User;
   import com.newcode.meeting.domain.Views;
   import com.newcode.meeting.dto.Role;
   import lombok.*;
  
   import java.net.URL;
   import java.time.LocalDate;
   import java.time.LocalDateTime;
   import java.util.Set;
  
   @Data
   @EqualsAndHashCode(of = "id")
   @AllArgsConstructor
   @RequiredArgsConstructor
   @Getter
   @Setter
   @ToString(of = {"id", "meLiked"})
   @JsonView(Views.FullProfileDetail.class)
  public class UserDto {
    private Long id;
    private String username;
    private URL userpic;
    private Gender gender;
    private LocalDate birthDate;
    private boolean isOnline;
    private Set&lt;Role&gt; roles;
    private boolean active;
    private String region;
    private String country;
    private LocalDateTime lastVisit;
    private ProfileDetail profileDetail;
    @JsonView(Views.FullProfileDetailImage.class)
    private Set&lt;Image&gt; images;
    private boolean meLiked;
    Integer likeNew;
  
  public UserDto(User user, boolean meLiked) {
      this.id = user.getId();
      this.username = user.getUsername();
      this.userpic = user.getUserpic();
      this.gender = user.getGender();
      this.birthDate = user.getBirthDate();
      this.isOnline = user.isOnline();
      this.roles = user.getRoles();
      this.active = user.isActive();
      this.region = user.getRegion();
      this.country = user.getCountry();
      this.lastVisit = user.getLastVisit();
      this.profileDetail = user.getProfileDetail();
      this.images = user.getImages();
      this.meLiked = meLiked;
      this.likeNew = user.getLikeNew();
  }
  }
  
   public UserPageDto getAllUser(User user, String ageMax, String ageMin, String gender, Pageable pageable) {
      user = userRepo.findUserById(user.getId());
  
      LocalDate minDate = getDateForSearchUser(ageMin);
      LocalDate maxDate = getDateForSearchUser(ageMax);
      Gender sex;
  
      if (gender.equals(Gender.FEMALE.toString())) {
          sex = Gender.MALE;
      } else {
          sex = Gender.FEMALE;
      }
      Page&lt;UserDto&gt; page = userRepo.findUsersByBirthDateIsBetweenAndGenderDto(pageable, maxDate, minDate, sex, user);
      return new UserPageDto(
              page.getContent(),
              page.getNumber(),
              page.getTotalPages());
  }
  </code></pre>
  
  <p>When I added "Pageable" I started getting this error.
  But the result is getting the right.
  Without "Pageable" or param "user"  works without errors</p>
  
  <p>The question is how to remove this error?</p>