Spring Web Application仅在我使用多个命名查询时才提供404

时间:2016-05-26 16:28:38

标签: java spring jpa web-applications named-query

这个问题让我很生气。我正在使用Spring with JPA创建一个Web应用程序。问题出在我的下面的代码中。当代码如下所示,我可以将我的Web应用程序完美地部署到我的localhost和AWS:

@Entity
@NamedQuery(name = "DayTotalPeople.updateTotal", query = "update DayTotalPeople d set d.totalPeople =?1 where d.date =?2 AND d.venue =?3")

public class DayTotalPeople {

  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  private Integer id;

  private LocalDate date;

  private Integer totalPeople;

  @ManyToOne
  @JoinColumn(name = "venue_id")
  @JsonBackReference
  private Venue venue;

  public DayTotalPeople() {}

  public DayTotalPeople(LocalDate date, Integer totalPeople, Venue venue) {
    this.date = date;
    this.totalPeople = totalPeople;
    this.venue = venue;
  }

//getters & setters

}

但是,当我为该类添加另一个命名查询时,如下所示,当我尝试在localhost和AWS上访问该应用程序时,我得到404。

 @Entity
 @NamedQueries({
    @NamedQuery(name = "DayTotalPeople.updateTotal", query = "update DayTotalPeople d set d.totalPeople =?1 where d.date =?2 AND d.venue =?3"),
    @NamedQuery(name = "DayTotalPeople.findSumPeopleByVenueAndDateBetween", query = "select sum(d.totalpeople) from DayTotalPeople d where d.venue=?1 and d.date between ?2 and ?3")
})
public class DayTotalPeople {
.....

我根本不明白这是怎么回事。任何人都可以解释为什么我甚至无法访问主页由于上述原因?谢谢!

0 个答案:

没有答案