【问题标题】:Problem compiling: [SELECT c FROM Client c ORDER BY c.id]. [32, 36] The state field path 'c.id' cannot be resolved to a valid type编译问题:[SELECT c FROM Client c ORDER BY c.id]。 [32, 36] 状态字段路径 \'c.id\' 无法解析为有效类型
【发布时间】:2023-01-02 00:09:40
【问题描述】:

enter image description here enter 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 中尝试过,但我从未解决过。

【问题讨论】:

    标签: java eclipse view vaadin


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2014-03-07
      • 2013-12-02
      • 2015-04-15
      • 2017-08-25
      • 2016-02-26
      • 1970-01-01
      • 2015-04-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多