title: Spring hibernate what @param gonna map to
body: <p>I have this Pojo as my hibernate entity, I am trying to use hibernate to update some rows in my table:</p>
  
  <pre><code>@Entity
  public class Money {
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Column(name = "id", unique = true, updatable = false, nullable = false)
      private Long id;
  
      @Column(name = "userid")
      private String userid;
  
      @Column(name = "email")
      private String email;
  
      @Column(name = "money")
      private double money;
  
      @Column(name = "status")
      private String status;
  
      @Column(name = "group_transaction_id")
      private String group_transaction_id;
  
  
      @Column(name = "item_transaction_id")
      private String item_transaction_id;
  
      @Column(name = "created_at")
      @CreationTimestamp
      private Date createdAt;
  
      @Column(name = "updated_at")
      private Date updated_at;
  
      public Long getId() {
          return id;
      }
  
      public String getUserid() {
          return userid;
      }
  
      public void setUserid(String userid) {
          this.userid = userid;
      }
  
      public String getEmail() {
          return email;
      }
  
      public void setEmail(String email) {
          this.email = email;
      }
  
      public double getMoney() {
          return money;
      }
  
      public void setMoney(double money) {
          this.money = money;
      }
  
      public String getStatus() {
          return status;
      }
  
      public void setStatus(String status) {
          this.status = status;
      }    
  
      public Date getCreatedAt() {
          return createdAt;
      }
  
      public void setCreatedAt(Date createdAt) {
          this.createdAt = createdAt;
      }
  
      public Date getUpdated_at() {
          return updated_at;
      }
  
      public void setUpdated_at(Date updated_at) {
          this.updated_at = updated_at;
      }
  
  }
  </code></pre>
  
  <p>What I am trying to do is:</p>
  
  <pre><code>@Repository
  public interface MoneyRepository extends CrudRepository&lt;Winners, Long&gt; {
  
      List&lt;Winners&gt; findAll();
  
      List&lt;Winners&gt; findByUseridAndStatus(String userid, String status);
  
      @Modifying(clearAutomatically = true)
      @Transactional
      @Query(value = "UPDATE Money w SET w.status = :status WHERE id in :ids")
      int testUpdate(@Param("status") String status, @Param("id") List&lt;Long&gt; ids);
  }
  </code></pre>
  
  <p>And in my Controller/Service I am using it like:</p>
  
  <pre><code>@Autowired
  PayoutRepository payoutRepository;
  
  public int testUpdateDB() {
  
      List&lt;Long&gt; pendingIds = Arrays.asList(1l, 2l);
  
      int affected = payoutRepository.testUpdate("pending", pendingIds);
  
          return affected;
      }
  </code></pre>
  
  <p>If I don't use  <code>@Param("id") List&lt;Long&gt; ids</code> it's complaining about </p>
  
  <blockquote>
    <p>java.lang.IllegalStateException: For queries with named parameters you
    need to use provide names for method parameters. Use @Param for query
    method parameters, or when on Java 8+ use the javac flag -parameters.   </p>
  </blockquote>
  
  <p>If I use <code>@Param("id") List&lt;Long&gt; ids</code> it's complaining :   </p>
  
  <blockquote>
    <p>org.hibernate.QueryException: Named parameter [ids] not set</p>
  </blockquote>
  
  <p>And if change my query to <code>@Query(value = "UPDATE Money w SET w.status = :status WHERE id in :id")</code> without changing anything else (just changed :ids to :id) it works. Can some explain how that mapping works?</p>