JPQL/HQL ERROR: syntax error at end of input with LEFT JOIN

JPQL/HQL ERROR: syntax error at end of input with LEFT JOIN

我在尝试执行以下查询时收到 错误:输入末尾的语法错误

SELECT appointment FROM Appointment appointment LEFT JOIN DoctorFacilityAppointment dfa

谁能告诉我为什么会出现此错误?

约会class

public class Appointment implements Serializable {
        
   private static final long serialVersionUID = 1L;
        
   @Id
   @GeneratedValue(strategy = GenerationType.IDENTITY)
   private int id;
        
   @Column(name="start_time")
   private LocalDateTime startTime;
        
   @Column(name="is_valide")
   private boolean isValid;
        
   @ManyToOne
   @JoinColumn(name = "patient_id", referencedColumnName = "id")
   private Patient patient;
    
}

医生设施预约

public class DoctorFacilityAppointment implements Serializable {
        
   private static final long serialVersionUID = 1L;
        
   @Id
   @GeneratedValue(strategy = GenerationType.IDENTITY)
   private int id;
        
   @ManyToOne
   @JoinColumn(name = "appointment_id", referencedColumnName = "id")
   private Appointment appointment;
        
   @ManyToOne
   @JoinColumn(name = "doctor_service_id", referencedColumnName = "id")
   private DoctorFacility doctorFacility;
}

JPQL/HQL join 应引用相应实体的关联或 component/embedded 属性。

所以,正确的查询应该是这样的:

select app from DoctorFacilityAppointment dfa left join dfa.appointment app