简体   繁体   中英

havaing error in jpql query

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.

this line is wrong:

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

should be:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM