简体   繁体   English

来自已编译实体类的EclipseLink Canonical Metamodel

[英]EclipseLink Canonical Metamodel from already compiled entity classes

I cannot seem to figure out how I should get EclipseLink's CanonicalModelProcessor to generate metadata classes for entities that are mapped in an orm.xml file, and which are not source files in the current compilation unit, but instead included in the compiler's classpath. 我似乎无法弄清楚如何使EclipseLink的CanonicalModelProcessor为映射在orm.xml文件中的实体生成元数据类,这些实体不是当前编译单元中的源文件,而是包含在编译器的类路径中。

I'm trying to do this with maven, by simply calling the compiler plugin without any further options. 我试图通过简单地调用编译器插件而不使用任何其他选项来使用maven。 I could verify that the EclipseLink annotation processor executes, and finds both the persistence.xml and the orm.xml, and succeeds in processing both files. 我可以验证EclipseLink注释处理器是否已执行,并找到了persistence.xml和orm.xml,并成功处理了这两个文件。 It only fails when it internally walks through the "RoundElement" classes and tries to map the against what is defined in the persistence unit. 它仅在内部遍历“ RoundElement”类并尝试将其与持久性单元中定义的内容映射时失败。 Obviously, the classes from the classpath are not in the "roundElements" list, and thus no code is generated for them, even though their metadata is present and valid in the internal PersistenceUnit object. 显然,来自类路径的类不在“ roundElements”列表中,因此即使它们的元数据在内部PersistenceUnit对象中存在并有效,也不会为它们生成任何代码。

Does anyone have an idea how I could get this to work? 有谁知道如何使它起作用? Thanks! 谢谢!

EDIT: excerpt of pom.xml: 编辑: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>

Excerpt from orm.xml: 摘自orm.xml:

...
<entity class="com.model.app.AppClass">
    .... AppClass is defined in app-model artifact
</entity>

OK - looking at the source code of the EclipseLink annotation processor, it seems that this is just "not possible". OK-查看EclipseLink注释处理器的源代码,看来这只是“不可能”。 The AP walks the source elements encountered by the compiler and matches them against what has been loaded from the JPA metamodel - not the other way round. AP遍历编译器遇到的源元素,并将其与从JPA元模型加载的元素进行匹配-并非相反。 Now, I created myself a patched version of the EclipseLink annotation processor that additionally walks the entities, embeddables and mapped superclasses defined in XML and matches them against binary elements from the compile-time classpath. 现在,我为自己创建了EclipseLink注释处理器的补丁版本,该补丁版本还遍历了XML中定义的实体,可嵌入对象和映射超类,并将它们与来自编译时类路径的二进制元素进行匹配。 This way, the full metamodel can be generated. 这样,可以生成完整的元模型。

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

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