title: How to make repository findBy() with more than one field in Spring Boot?
body: <p>I want to make restcontroller findbyProductIdandYear in Spring Boot java aplication, but I get error, How to make it in great way?</p>
  
  <p>Here is my model:</p>
  
  <pre><code>   @Entity
     @Table(name="view_disbursement_by_project")
     public class ViewDisbursement {
  
  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  @Column(name="id")
  private int id;
  
  @Column(name="project_id")
  private String projectId;
  
  @Column(name="stage")
  private String stage;
  
  @Column(name="no")
  private Integer no;
  
  @Column(name="months")
  private Integer months;
  
  @Column(name="years")
  private Integer years;
  
  @Column(name="count")
  private Integer count;
  
  public int getId() {
      return id;
  }
  
  public void setId(int id) {
      this.id = id;
  }
  
  public String getProject_id() {
      return projectId;
  }
  
  public void setProject_id(String project_id) {
      this.projectId = project_id;
  }
  
  public String getStage() {
      return stage;
  }
  
  public void setStage(String stage) {
      this.stage = stage;
  }
  
  public Integer getNo() {
      return no;
  }
  
  public void setNo(Integer no) {
      this.no = no;
  }
  
  public String getProjectId() {
      return projectId;
  }
  
  public void setProjectId(String projectId) {
      this.projectId = projectId;
  }
  
  public Integer getMonths() {
      return months;
  }
  
  public void setMonths(Integer months) {
      this.months = months;
  }
  
  public Integer getYears() {
      return years;
  }
  
  public void setYears(Integer years) {
      this.years = years;
  }
  
  public Integer getCount() {
      return count;
  }
  
  public void setCount(Integer count) {
      this.count = count;
  }
  
      }
  </code></pre>
  
  <p>Here is my repository:</p>
  
  <pre><code>    @Repository
      public interface ViewDisbursementRepository extends 
      JpaRepository&lt;ViewDisbursement, Integer&gt; {
  
  List&lt;ViewDisbursement&gt; findByProjectIdandYear(String projectId, 
      Integer years);
  
      }
  </code></pre>
  
  <p>Here is my service:</p>
  
  <pre><code>    @Service
      public class ViewDisbursementService {
  
  @Autowired
  ViewDisbursementRepository vdr;
  
   public ArrayList&lt;ViewDisbursement&gt; getAll(){
         ArrayList&lt;ViewDisbursement&gt; list = new 
             ArrayList&lt;ViewDisbursement&gt;();
         vdr.findAll().forEach(list::add);
         return list;
      }
  
   public List&lt;ViewDisbursement&gt; getProjectDisbursement(String id, Integer year){
       return vdr.findByProjectIdandYear(id, year);
   }
  </code></pre>
  
  <p>And here is my controller:</p>
  
  <pre><code>      @RestController
        @RequestMapping(path = "/dashboard")
        public class ViewDisbursementController {
       private static final Logger l = 
        LoggerFactory.getLogger(ViewDisbursementController.class);
  
    @Autowired
    ViewDisbursementService vds;
  
        @GetMapping(path = "/disbursement/{id}/{year}")
  
        public HighchartData getDisbursement(@PathVariable String id, Integer year)
  {
        l.info("getting id : " + id);
  
        List&lt;ViewDisbursement&gt; lvd = vds.getProjectDisbursement(id, year);
  
        l.info(lvd.size() + "");
  
        List&lt;ViewDisbursement&gt; lvdActual = new ArrayList&lt;ViewDisbursement&gt;();
        List&lt;ViewDisbursement&gt; lvdPlan = new ArrayList&lt;ViewDisbursement&gt;();
  
  
      // Dipilah berdasarkan stage
      for (ViewDisbursement d : lvd) {
          if (d.getStage().equals("ACTUAL")) 
              lvdActual.add(d);
          else
              lvdPlan.add(d); 
      }
  
      // Total Plan
      Integer totalPlan = 0;
      for (ViewDisbursement d : lvdPlan) {
          totalPlan += d.getCount();
      }
      l.info("Total " + totalPlan);
  
      // Plan
      List&lt;Double&gt; plan = new ArrayList&lt;Double&gt;();
      double currentPlan = 0;
      //Iterasi berdasarkan bulan
      for (int i = 1; i &lt;= 12; i++) {
          Integer count = getCount(lvdPlan, i);
          double current = ( count / (double) totalPlan) * 100;
          plan.add( current + currentPlan);
          currentPlan +=  current;
      }
      for (Double d : plan) {
          l.info("Nilai Plan " + d);
      }
  
      // Actual
      List&lt;Double&gt; actual = new ArrayList&lt;Double&gt;();
      double currentActual = 0;
      //Iterasi berdasarkan bulan
      for (int i = 1; i &lt;= 12; i++) {
          Integer count = getCount(lvdActual, i);
          double current = ( count / (double) totalPlan) * 100;
          actual.add( current + currentActual);
          currentActual +=    current;
      }
      for (Double d : actual) {
          l.info("Nilai Actual " + d);
      }
  
  
      // Nilainya sudah lengkap
      // Masukkan ke Highchart
  
      HighchartData result = new HighchartData();
      ChartData chart = new ChartData("line");
      TitleData title = new TitleData("Disbursement");
      AxisData xAxis = new AxisData();
      xAxis.setCategories(new String[] {
              "JAN", "FEB", "MAR",
              "APR", "MEI", "JUN",
              "JUL", "AUG", "SEP",
              "OKT", "NOV", "DES"});
  
  
      SeriesData series = new SeriesData();
      series.setName("PLAN");
      series.setData(plan.toArray(new Double[plan.size()]));
  
      SeriesData series2 = new SeriesData();
      series2.setName("ACTUAL");
      series2.setData(actual.toArray(new Double[actual.size()]));
  
      result.setChart(chart);
      result.setTitle(title);
      result.setxAxis(xAxis);
      result.setSeries(new SeriesData[] {series, series2});
  
      return result;
      }
  
       private Integer getCount(List&lt;ViewDisbursement&gt; lvd, Integer month) {
      for (ViewDisbursement d : lvd) {
          if(d.getMonths() == month)
              return d.getCount();
      }
      return 0;
      }
      }
  </code></pre>
  
  <p>After running the program I get this error:</p>
  
  <pre><code>    Error starting ApplicationContext. To display the conditions report 
      re-run your application with 'debug' enabled.
      2019-08-01 11:52:44.573 ERROR 9408 --- [           main] 
      o.s.boot.SpringApplication               : Application run failed
  
      org.springframework.beans.factory.UnsatisfiedDependencyException: 
      Error creating bean with name 'viewDisbursementController': 
      Unsatisfied dependency expressed through field 'vds'; nested exception 
      is org.springframework.beans.factory.UnsatisfiedDependencyException: 
      Error creating bean with name 'viewDisbursementService': Unsatisfied 
      dependency expressed through field 'vdr'; nested exception is 
      org.springframework.beans.factory.BeanCreationException: Error 
      creating bean with name 'viewDisbursementRepository': Invocation of 
      init method failed; nested exception is 
      java.lang.IllegalArgumentException: Failed to create query for method 
      public abstract java.util.Listcom.fusi24.pmorest.repository.ViewDisbursementRepository.findByP 
      rojectIdandYear(java.lang.String,java.lang.Integer)! No property 
      projectIdandYear found for type ViewDisbursement!
  </code></pre>