使用EclipseLink,遍布多个jar的实体的静态编织失败

时间:2012-11-05 10:30:29

标签: java jpa orm eclipselink

我有几个实体分布在多个罐子里。 位于jar X中的实体包含jar Y中的实体集合。 当我尝试在jar X上进行静态编织时,我收到以下错误:

  

异常描述:[class MyEntity]在关系属性[method getMyOtherEntities]中使用非实体[class MyOtherEntity]作为目标实体。

错误与以下堆栈有关:

  

at org.eclipse.persistence.exceptions.ValidationException.nonEntityTargetInRelationship(ValidationException.java:1360)       at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.RelationshipAccessor.getReferenceDescriptor(RelationshipAccessor.java:538)       at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.RelationshipAccessor.processJoinTable(RelationshipAccessor.java:692)       在org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.ManyToManyAccessor.process(ManyToManyAccessor.java:160)       在org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processOwningRelationshipAccessors(MetadataProject.java:1489)       在org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processStage3(MetadataProject.java:1726)       在org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processORMMetadata(MetadataProcessor.java:535)       在org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:550)       在org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1469)

这两个实体都使用@Entity注释,并且在Hibernate中运行良好 这两个类都在类路径中,我在调试器中检查了MyOtherEntity是否被找到并按预期注释。

当实体分布在多个罐子中时,是否可以使用静态编织?

1 个答案:

答案 0 :(得分:0)

你可以尝试在编织时指定依赖的jar

来自Ant EclipseLink weave Ant Task的片段

 <weave  source="c:\myjar.jar"
        target="c:\wovenmyjar.jar"
        persistenceinfo="c:\myjar-containing-persistenceinfo.jar">
    <classpath>
        <pathelement path="c:\myjar-dependent.jar"/>
    </classpath>

</weave>