【发布时间】:2015-04-23 00:29:12
【问题描述】:
我似乎无法弄清楚我应该如何让 EclipseLink 的 CanonicalModelProcessor 为映射在 orm.xml 文件中的实体生成元数据类,这些实体不是当前编译单元中的源文件,而是包含在编译器的类路径中.
我正在尝试使用 maven 执行此操作,只需调用编译器插件而无需任何其他选项。我可以验证 EclipseLink 注释处理器是否执行,并找到 persistence.xml 和 orm.xml,并成功处理这两个文件。只有当它在内部遍历“RoundElement”类并尝试映射持久性单元中定义的内容时才会失败。显然,类路径中的类不在“roundElements”列表中,因此不会为它们生成任何代码,即使它们的元数据在内部 PersistenceUnit 对象中存在且有效。
有人知道我怎样才能让它工作吗? 谢谢!
编辑: pom.xml 摘录:
<dependencies>
<dependency>
<groupId>com.model</groupId>
<artifactId>app-model</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.5.2</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa.modelgen.processor</artifactId>
<version>2.5.2</version>
</dependency>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
</plugins>
</build>
摘自 orm.xml:
...
<entity class="com.model.app.AppClass">
.... AppClass is defined in app-model artifact
</entity>
【问题讨论】:
-
不清楚您尝试运行 CanonicalModelProcessor 的持久性单元的结构 - 与您的 persistence.xml 相关的实体类文件在哪里?
-
实体类文件在一个预编译的jar中,作为maven工件添加到包含persistence.xml和orm.xml的模块的maven pom中。我希望注释处理器解析 orm.xml 文件,然后尝试解析其中提到的类,无论它们是在当前模块的源代码中找到还是作为上游模块中的已编译类文件。然而,情况似乎并非如此。我将尝试编辑我的原始帖子并添加一些示例代码 sn-ps 以澄清...
标签: java jpa annotations eclipselink metamodel