注释——未知实体

注释——未知实体

本文介绍了Hibernate/JPA 注释——未知实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个运行良好数月的应用程序已停止接收 JPA @Entity 注释,该注释已成为它的一部分数月.在我的集成测试运行时,我看到数十个org.hibernate.MappingException: Unknown entity: com.whatever.OrderSystem"类型错误.

An application that has been working well for months has stopped picking up the JPA @Entity annotations that have been a part of it for months. As my integration tests run I see dozens of "org.hibernate.MappingException: Unknown entity: com.whatever.OrderSystem" type errors.

我不清楚这里出了什么问题.

It isn't clear to me what's gone wrong here.

我没有 hibernate.cfg.xml 文件,因为我使用的是 Hibernate Entity Manager.由于我只使用注释,因此我的实体没有 .hbm.xml 文件.我的 persistence.xml 文件很小,并且按预期位于 META-INF 中.

I have no hibernate.cfg.xml file because I'm using the Hibernate Entity Manager. Since I'm exclusively using annotations, there are no .hbm.xml files for my entities. My persistence.xml file is minimal, and lives in META-INF as it is supposed to.

我显然遗漏了一些东西,但我无法找到它.

I'm obviously missing something but can't put my finger on it.

我正在使用 hibernate-annotations 3.2.1、hibernate-entitymanager 3.2.1、persistence-api 1.0 和 hibernate 3.2.1.hibernate-commons-annotations 也是项目 POM 的一部分,但我不知道这是否相关.

I'm using hibernate-annotations 3.2.1, hibernate-entitymanager 3.2.1, persistence-api 1.0 and hibernate 3.2.1. hibernate-commons-annotations is also a part of the project's POM but I don't know if that's relevant.

是否存在已消失的 web.xml 条目,或意外删除的 Spring 配置条目?

Is there a web.xml entry that has vanished, or a Spring configuration entry that has accidentally been deleted?

推荐答案

我似乎记得我曾经遇到过类似的问题.

I seem to recall I had a similar issue at one time.

这是一个长期的尝试,但如果您还没有这样做,您是否明确指定了您正在使用的提供程序?

Its a long shot, but if you're not already doing this, have you explicitly specified the provider you are using?

<persistence ...>
   <persistence-unit ...>
      <provider>org.hibernate.ejb.HibernatePersistence</provider> <---- explicit setting
      ....
   </persistence-unit>
</persistence>

否则,我不确定?

这篇关于Hibernate/JPA 注释——未知实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 02:10