简体   繁体   English

从持久性中排除@Entity

[英]exclude @Entity from persistence

I am using persistence.xml in hibernate 我在休眠状态下使用persistence.xml

However, I am some @Entity in the classpath which I don't them to be part of persistence.xml. 但是,我是类路径中的某个@Entity,但我不是它们要成为persistence.xml的一部分。

in the documentation 在文档中

class The class element specifies a fully qualified class name that you will map. class class元素指定您将映射的完全限定的类名称。 By default all properly annotated classes and all hbm.xml files found inside the archive are added to the persistence unit configuration. 默认情况下,在存档中找到的所有正确注释的类和所有hbm.xml文件都添加到持久性单元配置中。

Is there to exclude some entities from it? 是否要从中排除某些实体?

It's not possible afaik. 这是不可能的。 But don't worry about that - if you don't use these classes they will not bother you, apart from their metadata being loaded by the session factory. 但是不必担心-如果您不使用这些类,那么它们将不会打扰您,除了会话工厂正在加载其元数据外。

Update: hbm2ddl tools (like ant) have the excludes option. 更新: hbm2ddl工具(如ant)具有excludes选项。 I don't know how you are using it, so search for options there. 我不知道您如何使用它,因此请在此处搜索选项。

Apart from this, you can manually list all classes in persistence.xml and use: 除此之外,您可以手动列出persistence.xml中的所有类并使用:

<exclude-unlisted-classes>true</exclude-unlisted-classes>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM