我创建了一个JoinTable作为注释,因此我没有该数据库模式的实体。这就是我收到此错误的原因:
“引起:异常[EclipseLink-0](Eclipse Persistence Services - 2.6.1.v20150605-31e8258):org.eclipse.persistence.exceptions.JPQLException 异常描述:编译问题[SELECT it FROM itinerary_flight it WHERE it.itineraryTraveller_id =:id]。 [15,31]抽象模式类型'itinerary_flight'未知。 [41,65]状态字段路径'it.itineraryTraveller_id'无法解析为有效类型。“。
我在这里创建了连接表:`
@Entity
public class itineraryTraveller implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long Id;
private String departureLocation;
private String arrivalLocation;
@ManyToMany(fetch = FetchType.LAZY)
//@JoinTable(name="ITINERARYTRAVELLER_FLIGHT")
@JoinTable(name = "itinerary_flight",
joinColumns = @JoinColumn(name = "itineraryTraveller_id"),
inverseJoinColumns = @JoinColumn(name = "flightEntity_id")
)
private List<flightEntity> flights;
当我尝试选择该连接表时,我收到上面的错误信息。这里是查询:
Query query= em.createQuery("SELECT it FROM Itinerary_flight it WHERE it.itineraryTraveller_id = :id");
query.setParameter("id", listOfItineraries.get(i).getId());
List<flightEntity> list= query.getResultList();
答案 0 :(得分:0)
SELECT ti FROM TravellerItinerary ti JOIN ti.flights fl WHERE fl.id = :id
但是你没有发布相关实体,所以要说更多不可能