Joe*_*ore 5 java jpa eclipselink
我有一个使用 Eclipselink 2.5 的应用程序,在运行 Junit 测试用例时,我总是收到此警告:
[EL Warning]: metadata: 2013-08-19 01:14:05.142--ServerSession(14351551)--
Reverting the lazy setting on the OneToOne or ManyToOne attribute [currentTransit]
for the entity class [class ......persistent.entity.BPExecutionEntity] since
weaving was not enabled or did not occur.
Run Code Online (Sandbox Code Playgroud)
所以,我在 Ant 构建文件上写了一个“编织”任务,如下所示:
<target name="define.task" description="New task definition for EclipseLink static weaving">
<taskdef name="weave" classname="org.eclipse.persistence.tools.weaving.jpa.StaticWeaveAntTask"/>
</target>
<target name="weaving" description="perform weaving" depends="define.task">
<weave source="D:\...\dist\${ant.project.name}.jar"
target="D:\...\dist\woven-${ant.project.name}.jar"
persistenceinfo="D:\...\lib\persistence.jar">
<classpath>
</classpath>
</weave>
</target>
Run Code Online (Sandbox Code Playgroud)
好的,一切正常,当我编译代码时,它会生成一个大小为已编译 jar 一半大小的编织文件。但是,当我运行项目的测试时,我仍然收到相同的警告blah blah blah... since weaving was not enabled or did not occur.
有人知道如何从我的测试中删除此警告吗?
最后我用动态编织解决了这个问题。由于我使用的是 Netbeans 7.3.1,因此我转到Project Options | Run | VM options并添加了以下文本:-javaagent:C:\eclipselink\jlib\eclipselink.jar,您可以将地址更改为您在 eclipselink.jar 中找到的任何地址。
然后我将这一行添加到persistence.xml:
<property name="eclipselink.weaving" value="true"/>
Run Code Online (Sandbox Code Playgroud)
就这样。此配置允许动态编织来执行测试用例并删除[EL Warning] Reverting the lazy setting on the OneToOne or ManyToOne attribute...etc.