当我运行使用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
如何启用静态编织???我一团糟
答案 0 :(得分:1)
我认为你的问题是源应该是jar,而不是目录。尝试给它一个编译类的jar。
请参阅,
答案 1 :(得分:0)
使用 DALI SETTINGS 在Eclipse中打开它。请注意,我必须打开Projects-&gt; Build Automatically设置,否则它会不断重建文件!
答案 2 :(得分:0)
您缺少persistence.xml中的静态编织声明:
<properties>
...
<property name="eclipselink.weaving" value="static"/>
...
</properties>
答案 3 :(得分:0)
您需要在persistence.xml中拥有该属性
<property name="eclipselink.weaving" value="static"/>
如果您愿意,可以使用展开的目录结构而不是jar文件。
当persistenceinfo位置中有空格时我遇到了问题所以我在编织它们之前将persistence.xml文件移动到要编织的类文件的位置。