4

当我运行使用 jpa 的 rcp 应用程序时,我收到以下警告消息:

[EL Info]: 2012-05-23 22:29:26.841--ServerSession(20341825)--EclipseLink, version: Eclipse Persistence Services - 2.3.2.v20111125-r10461
[EL Warning]: 2012-05-23 22:29:27.338--ServerSession(20341825)--Reverting the lazy setting on the OneToOne or ManyToOne attribute [infoid] for the entity class [class org.company.management.entity.Employee] since weaving was not enabled or did not occur.
[EL Warning]: 2012-05-23 22:29:27.339--ServerSession(20341825)--Reverting the lazy setting on the OneToOne or ManyToOne attribute [groupid] for the entity class [class org.company.management.entity.Employee] since weaving was not enabled or did not occur.
[EL Warning]: 2012-05-23 22:29:27.339--ServerSession(20341825)--Reverting the lazy setting on the OneToOne or ManyToOne attribute [employeeSchedule] for the entity class [class org.company.management.entity.Employee] since weaving was not enabled or did not occur.
[EL Warning]: 2012-05-23 22:29:27.34--ServerSession(20341825)--Reverting the lazy setting on the OneToOne or ManyToOne attribute [employeescheduleid] for the entity class [class org.company.management.entity.EmployeeScheduleInfo] since weaving was not enabled or did not occur.
[EL Warning]: 2012-05-23 22:29:27.34--ServerSession(20341825)--Reverting the lazy setting on the OneToOne or ManyToOne attribute [scheduleid] for the entity class [class org.company.management.entity.EmployeeSchedule] since weaving was not enabled or did not occur.
[EL Warning]: 2012-05-23 22:29:27.34--ServerSession(20341825)--Reverting the lazy setting on the OneToOne or ManyToOne attribute [employeeid] for the entity class [class org.company.management.entity.EmployeeSchedule] since weaving was not enabled or did not occur.
[EL Warning]: 2012-05-23 22:29:27.341--ServerSession(20341825)--Reverting the lazy setting on the OneToOne or ManyToOne attribute [employee] for the entity class [class org.company.management.entity.EmployeeInfo] since weaving was not enabled or did not occur.
[EL Info]: 2012-05-23 22:29:27.556--ServerSession(20341825)--bundleresource://29.fwk31583837:2_Management login successful

我想启用延迟加载。

我的 persistence.xml 看起来像这样:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="Management" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>org.company.management.entity.EmployeeGroup</class>
<class>org.company.management.entity.Company</class>
<class>org.company.management.entity.Employee</class>
<class>org.company.management.entity.Schedule</class>
<class>org.company.management.entity.EmployeeInfo</class>
<class>org.company.management.entity.EmployeeSchedule</class>
<class>org.company.management.entity.EmployeeScheduleInfo</class>

<properties>
  <property name="javax.persistence.jdbc.url" value="jdbc:derby:.cafedb;create=true"/>
  <property name="javax.persistence.jdbc.password" value="vodbomb"/>
  <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver"/>
  <property name="javax.persistence.jdbc.user" value="root"/>

  <property name="eclipselink.ddl-generation" value="create-tables" />
</properties>
</persistence-unit>
</persistence>

我有一个构建脚本“build.xml”来进行静态编织:

<project name="Management" basedir=".">
<target name="define.task" description="New task definition for toplink static weaving">
<taskdef name="weave" classname="org.eclipse.persistence.tools.weaving.jpa.StaticWeaveAntTask">
</taskdef>
</target>    
<target name="weaving" description="perform weaving" depends="define.task"
<weave  source="${basedir}/src/org/company/management/entity"
                target="${basedir}/src/org/company/management/entity/woven.jar"
                persistenceinfo="${basedir}/META-INF/persistence.xml">     
</weave>
</target>
</project>

当我运行 ant 脚本“build.xml”时,我遇到了这个错误:

Buildfile: C:\Users\J\workspace\org.company.management\build.xml
define.task:
weaving:

BUILD FAILED
C:\Users\J\workspace\org.company.management\build.xml:13: Exception [EclipseLink-40007]     (Eclipse Persistence Services - 2.3.2.v20111125-r10461):     org.eclipse.persistence.exceptions.StaticWeaveException
Exception Description: An exception was thrown while weaving:     C:\Users\J\workspace\org.company.management\src\org\company\management\entity
Internal Exception: Exception [EclipseLink-40001] (Eclipse Persistence Services -     2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.StaticWeaveException
Exception Description: An exception was thrown while trying to open an archive from     URL: file:/C:/Users/J/workspace/org.company.management/META-INF/persistence.xml 
Internal Exception: java.util.zip.ZipException: error in opening zip file

Total time: 242 milliseconds

如何启用静态编织???我一团糟

4

5 回答 5

2

如何在 Netbeans 中使用 Eclipse-Link JPA 应用静态编织 Ant 任务?

结合问题和答案,您将获得有效的示例。

于 2013-01-18T12:47:41.277 回答
1

我认为您的问题是源应该是 jar,而不是目录。尝试给它一个已编译类的 jar。

看,

http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Advanced_JPA_Development/Performance/Weaving/Static_Weaving

于 2012-05-24T13:35:52.330 回答
0

使用DALI SETTINGS在 Eclipse 中打开它。请注意,我必须打开 Projects->Build Automatically 设置,否则它会不断重建文件!

于 2013-12-14T18:03:34.550 回答
0

您在persistance.xml 中缺少静态编织声明:

<properties>
    ...
    <property name="eclipselink.weaving" value="static"/>
    ...
</properties>
于 2014-02-27T14:38:46.750 回答
0

您需要在 persistence.xml 中拥有该属性

<property name="eclipselink.weaving" value="static"/>

如果您愿意,可以使用展开的目录结构而不是 jar 文件。

当persistenceinfo位置中有空格时我遇到了问题,所以我在编织它们之前将我的persistence.xml文件移动到要编织的类文件的位置。

于 2014-03-12T14:42:49.273 回答