线程“主”中的异常java.lang.IllegalArgumentException:

时间:2018-08-29 16:23:44

标签: hibernate

这是我的代码:

airelines = em.createQuery(
                    "select distinct rt.aireline from Route as rt join rt.aireline as a1"
                    + " join rt.destination as dst "
                    + " where a1.country = :country and dst.city = :city ", Airline.class)
                   .setParameter("country", "France")
                     .setParameter("city", "Miami")
                    .getResultList(); 

                            showAirlines(airelines);

我有这些错误。请,如何解决这些错误。此致。

   Exception in thread "main" java.lang.IllegalArgumentException:    
   org.hibernate.QueryException: could not resolve property: aireline of: flights.Route [select distinct rt.aireline from flights.Route as rt join rt.aireline as a1 join rt.destination as dst  where a1.country = :country and dst.city = :city ]
at 

这是我的路线课程:

@Entity
public class Route implements Serializable {
private String airlineCode;
@ManyToOne
@Id
private Airline airline;
private String sourceCode;
@ManyToOne
@Id
private Airport source;
private String destinationCode;
@ManyToOne
@Id
private Airport destination;
private Boolean codeshare;
private Short stops;
private String equipment;
 //Getters and Setters
}

非常感谢。请,如何解决这些错误。此致。

1 个答案:

答案 0 :(得分:2)

这只是一个拼写错误。在查询中使用 rt.aireline 时,您的实体中具有名为 airline 的属性。只需在查询中将 rt.aireline 替换为 rt.airline 。应该可以...