java - 从持久性中排除@Entity

标签 java hibernate jpa

我在 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/

相关文章:

java - 为什么在 java 中使用 request.getParameter() 时字符损坏?

java - spring hibernate多对多映射表单输入

java - jpa查询两个日期之间

java - Apache Commons IO Tailer 传送旧日志消息

java - 通过带有 JComboBox 元素的 JButton 做某事

java - 神经网络为每个输入返回相同的输出

java - Hibernate注释: Many-to-many with shared composite key attribute

java - 没有找到类 org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer 的序列化程序,也没有发现创建 BeanSerializer 的属性

java - CLOB 不保存在 ORACLE 上(使用 JPA、eclipselink)

java.lang.IllegalArgumentException : The attribute [A] from the managed type [T] is not present 异常