必须在persistence.xml中注册每个实体Bean? [英] Must every Entity Bean be registered in persistence.xml?

查看:316
本文介绍了必须在persistence.xml中注册每个实体Bean?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Eclipse Facets进行JPA 2.0和Hibernate 4.2实现。我想我记得在以前的项目中,我不必在persistence.xml中注册一个Entity Bean。我错了吗?



使用@Entity注释POJO(在这种情况下为Pub.java)会在Eclipse标记/问题视图中引发以下错误:

 类com.jacky.webapp.model.Pub被管理,但未列在persistence.xml文件Pub.java / webapp / src / main / java / com / jacky / webapp / model 

任何线索?谢谢。

解决方案

已经写下来的解决方案是:



检查您的JPA项目属性,并确保在持久类管理部分中选择自动发现注释类。这样做应该为您的用例提供正确的验证。


I'm using Eclipse Facets for JPA 2.0 and Hibernate 4.2 implementation. I think I recall that in previous project I would not have to register an Entity Bean in the persistence.xml. Am I mistaken?

Annotating a POJO (in this case Pub.java) with @Entity will throw the following error in the Eclipse marker/problem view:

Class "com.jacky.webapp.model.Pub" is managed, but is not listed in the persistence.xml file    Pub.java    /webapp/src/main/java/com/jacky/webapp/model    

Any clue? thanks.

解决方案

As already written here is the solution:

Check you JPA project properties and be sure to select "Discover annotated classes automatically" in the "Persistent class management" section. Doing this should provide the correct validation for your use case.

这篇关于必须在persistence.xml中注册每个实体Bean?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆