havaing error in jpql query

47 views Asked by At
public List<SchoolDTO> getSchoolList() throws FortuneEnterpriseException {
        List<School> listSchools=new ArrayList<School>();
        List<SchoolDTO> dto = null;
        SchoolMapper sMapper =new SchoolMapper();
        try{

            Query query=entityManager.createNamedQuery("SELECT e FROM School e");
            listSchools=query.getResultList();
            dto= new ArrayList<SchoolDTO>();
            for (School school : listSchools) {
                dto.add(sMapper.mapToDTO(school));
            }
            return dto;
        }catch(Exception ex){
            ex.printStackTrace();
            throw new FortuneEnterpriseException("appplication.error");
            }

        }

Error: 13:15:01,845 ERROR [stderr] (default task-21) java.lang.IllegalArgumentException: No query defined for that name [SELECT e FROM School e]

Tell me my mistake.
1

There are 1 answers

0
diufanman On

this line is wrong:

Query query=entityManager.createNamedQuery("SELECT e FROM School e");

should be:

Query query=entityManager.createQuery("SELECT e FROM School e");