0

I have written this query in spring boot, and I am getting this error while building the project. Any help?

@Query("SELECT Appointments.InsuranceBillingSequence"+
            "FROM PatientInfo P OUTER " +
            "APPLY (SELECT TOP 1 APT.InsuranceBillingSequence FROM [Appointments] APT" +
            "WHERE APT.LicenseKey=P.LicenseKey and APT.PatientFID = P.Patient_UID and" +
            "APT.Appointment_UID in ?3) Appointments" +
            "WHERE P.Id=?1 AND P.LicenseKey=?2")
    List<InsuranceDetailsDTO> findPatientInfoWithInsuranceDetails(String id, Integer licenseKey, 
                                                                  List<Integer> visits);

Error:- ast.ErrorCounter:org.hibernate.hql.internal.ast.ErrorCounter.reportError(ErrorCounter.java:60) - line 1:651: unexpected token: OUTER*

Thilan
  • 71
  • 6
  • 2
    OUTER APPLY is specific to SQLServer (google tells me), if you want to use it you'll have to run a native query. Otherwise you'll have to stick to what JPQL supports. – Gimby Feb 20 '20 at 10:32
  • 2
    Is `APPLY ` a supported JPQL keyword? Maybe you need `nativeQuery=true` – Alan Hay Feb 20 '20 at 10:32
  • Making it a native query solves the problem. Thank you both! – Thilan Feb 20 '20 at 11:05

0 Answers0