【问题标题】:Hibernate Reimb is not mappedHibernate Reimb 未映射
【发布时间】:2019-01-27 07:31:58
【问题描述】:

我之前遇到过这个错误,但这是因为我指向的是表名(用户)而不是类名(用户)。报销表和我的用户表存在于我的数据库中,我可以通过我的 DBeaver 脚本使用普通 SQL 命令从中提取信息。这次我完全不知道为什么我被告知它没有映射。

例外:Reimb 未映射

[Select reimb_id, firstname, lastname, amount, type_id, description, submit_date, status_id, resolve_date From Reimb Left join Users Order by status_id]

我的 Reimb 课程:

@Entity
@Table(name = "reimbursement", schema = "ers")
public class Reimb {

HQL 语句:

String hql = "Select reimb_id, firstname, lastname, amount, type_id, " +
                        "description, submit_date, status_id, resolve_date " +
                        "From Reimb " +
                        "Left join Users " +
                        "Order by status_id";

Query q = session.createQuery(hql).setMaxResults(20);

我已经尝试过 @Entity(name = "Reimb") 就像我在之前的解决方案中看到的那样,但这也没有帮助。

【问题讨论】:

  • 你是如何告诉 Hibernate 你的映射类存在的?你确定他们被认出来了吗?
  • 我使用注释而不是配置文件。 Users.java 类被识别,并且我正在组合的网站部分利用 HQL 语句中的 Users.java 类工作正常。 Reimb.java 给了我一些问题(如上所述)。

标签: java hibernate


【解决方案1】:

忘记加了

    configuration.addAnnotatedClass(Reimb.class);

到我的休眠配置。

【讨论】:

    猜你喜欢
    • 2019-06-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多