코딩 에러 및 질문

nested exception is org.hibernate.exception.SQLGrammarException: could not execute query

요가하는 개발자 2023. 8. 29. 14:45

🌳 에러 코드


java.sql.SQLException

"could not execute query; SQL [SELECT d.hospitalName, d.hospitalAddress, d.mapx, d.mapy, d.category, d.hospitalPhoneNumber, d.hospitalIntroduce, d.hospitalProfileURL FROM doctor d WHERE d.category = ?]; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query",

 

 

 

 

 

 

 

 

 

 

 

🌳 해결 방법


🌾 해결 방법 :  Doctor 엔티티를 사용하지 않고 interface 반환 타입을 만들어서 해결. 

https://www.baeldung.com/jpa-queries-custom-result-with-aggregation-functions

 

 

 

 

 

Before

 

 

 

 

 

 

 

After

public interface HospitalInterface {

    String getHospiatalName();
    String getHospitalAddress();

    String getMapx();

    String getMapy();

    String getCategory();

    Integer getHospitalPhoneNumber();

    String getHospitalIntroduce();

}