【问题标题】:Hibernate - my table is not mapped休眠 - 我的表未映射
【发布时间】:2013-05-04 09:08:41
【问题描述】:

我想用getValueByLabel 方法做一个简单的查询:

这是我的代码:

public Config getValueByLabel(String label) throws EntityPersistException{

    try {
        Query query = em.createQuery("select id from config where config_label=:label",Long.class);
        query.setParameter("label", label);
        List<Long> config = query.getResultList();

        return em.getReference(Config.class, config.get(0));
    }
...

当我想启动我得到的方法时:

org.hibernate.hql.internal.ast.QuerySyntaxException: config is not mapped [select id from config where config_label=:label]

有什么办法解决这个问题吗?

更新

我正在使用:

休眠 4.0.1.Final 和一个 postgresql db 1.16.1

【问题讨论】:

    标签: database hibernate postgresql


    【解决方案1】:

    hql 的语法区分大小写。请查看查询中使用的表/实体和列/实例变量名称是否与对象相同。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-02-05
      • 1970-01-01
      • 2013-02-09
      • 1970-01-01
      • 2019-12-03
      • 2020-12-18
      • 1970-01-01
      相关资源
      最近更新 更多