Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
给定一个数据库模式和两个(或更多)包。
问题:是否可以跨包分布 JPA 实体(对于单个模式)?
(我最初是在考虑片段包,但想知道是否还有其他可能性)
如果您的所有实体类都列在 persistence.xml 中,那么这是可能的。
确保 JPA 引擎使用的类加载器也能看到所有 Entity 类和 JPA 引擎的类!这取决于您使用的工具,如何解决这个问题。例如:一些扩展器使用包含persistence.xml 文件的包的类加载器与JPA 引擎的类加载器混合。在这种情况下,您必须导入包含 persistence.xml 的捆绑包在 persistence.xml 中使用的所有包。