eclipse 编译时出现问题:[SELECT c FROM Client c ORDER BY c.id]. [32,36]状态字段路径'c.id'无法解析为有效类型

xzlaal3s  于 2023-01-02  发布在  Eclipse
关注(0)|答案(1)|浏览(113)

enter image description hereenter image description here

`
// init Data Model
        private void initDataModel(){
        System.out.println("DEBUG START FORM >>> ");
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("ServiciiJPA");
        em = emf.createEntityManager();
        List<Client> lst = em
        .createQuery("SELECT c FROM Client c ORDER BY c.id", Client.class)
        .getResultList();
        clienti.addAll(lst);
        if (lst != null && !lst.isEmpty()){
        Collections.sort(this.clienti, (c1, c2) ->  c1.getId().compareTo(c2.getId()));
        this.client = clienti.get(0);
        System.out.println("DEBUG: client init >>> " + client.getId());
        }

我在Eclipse中尝试过,但从未解决。

klh5stk1

klh5stk11#

如果您使用JPA,请发布Client.class,否则请发布表创建代码以获取更多信息。但是在您的查询中,我建议将select更改为“SELECT c.* FROM Client c Order BY c.id“

相关问题