我在 hibernate 中使用 persistence.xml
但是,我是类路径中的一些 @Entity,但我不认为它们是 persistence.xml 的一部分。
在文档中
class The class element specifies a fully qualified class name that you will map. By default all properly annotated classes and all hbm.xml files found inside the archive are added to the persistence unit configuration.
是否可以排除某些实体?
最佳答案
据我所知这是不可能的。但不用担心 - 如果您不使用这些类,除了 session 工厂加载它们的元数据之外,它们不会打扰您。
更新: hbm2ddl
工具(如 ant)具有 excludes
选项。我不知道你是如何使用它的,所以在那里搜索选项。
除此之外,您还可以手动列出 persistence.xml
中的所有类并使用:
<exclude-unlisted-classes>true</exclude-unlisted-classes>
关于java - 从持久性中排除@Entity,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4848839/