如何在EclipseLink中启用编织? [英] How to enable weaving in EclipseLink?
问题描述
我在GlassFish终端上收到以下警告,同时部署一个在实体中具有延迟抓取的应用程序,
I receive the following warning on the GlassFish terminal while deploying an application that has lazy fetching in entities,
警告:恢复懒惰设置
OneToOne
或ManyToOne
属性[zoneTable]
为实体类[class entity.ZoneCharge]
,因为编织未启用或未发生。
WARNING: Reverting the lazy setting on the
OneToOne
orManyToOne
attribute[zoneTable]
for the entity class[class entity.ZoneCharge]
since weaving was not enabled or did not occur.
表示项目中列出的任何实体。
for whatever entities are listed in the project.
我的 persistence.xml
文件类似于以下内容。
My persistence.xml
file looks something like the following.
<?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="Project-ejbPU" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/pool</jta-data-source>
<class>entity.ZoneTable</class>
<!--Other classes-->
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.weaving" value="static"/>
<property name="eclipselink.target-server" value="SunAS9"/>
<property name="eclipselink.logging.parameters" value="true"/>
<property name="eclipselink.logging.level.sql" value="FINEST"/>
<property name="eclipselink.logging.level" value="FINEST" />
<property name="eclipselink.logging.level" value="WARNING"/>
<property name="eclipselink.logging.level.cache" value="FINEST"/>
</properties>
</persistence-unit>
</persistence>
ZoneTable
类似乎,
@Entity
@Table(name = "zone_table", catalog = "projectdb", schema = "")
public class ZoneTable implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "zone_id")
private Long zoneId;
@Column(name = "zone_name")
private String zoneName;
@OneToMany(mappedBy = "zoneTable", fetch = FetchType.LAZY)
private Set<ZoneCharge> zoneChargeSet;
//Setters and getters.
}
这里懒惰的提取工作甚至可以用于远程EJB,但我认为,它被认为是渴望因为上述警告。
Here lazy fetching works even with remote EJBs but I think, it is considered eager because of the above warning.
如何启用编织(或其他方式)以避免此警告?
How to enable weaving (or some other way) to avoid this warning?
当我输入此命令时,如此处,
When I enter this command as mentioned here,
java org.eclipse.persistence.tools.weaving.jpa.StaticWeave
命令行上的
我收到以下错误。
on the command line, I get the following error.
错误:无法找到或加载主要的classorg.eclipse.persistence.tools.weaving.jpa.StaticWeave
Error: could not find or load main classorg.eclipse.persistence.tools.weaving.jpa.StaticWeave
什么是克服此警告的方法?
What are the ways to overcome this warning?
推荐答案
确保您拥有带有 org.eclipse的EclipseLink.jar .persistence.tools.weaving.jpa.StaticWeave
o尝试运行该类进行静态编织时的类路径。
Make sure you have the EclipseLink.jar with the org.eclipse.persistence.tools.weaving.jpa.StaticWeave
on the classpath when trying to run that class for static weaving.
但如果您在GlassFish 4中运行,则不需要使用静态编织。删除< property name =eclipselink.weavingvalue =static/>
属性,然后再次尝试部署。此属性表示您的类已经静态增强,因此不应进行动态编织。由于它们没有得到增强,懒惰的1:1和M:1将默认为急切。
But if you are running in GlassFish 4 you should not need to use static weaving. Remove the <property name="eclipselink.weaving" value="static"/>
property and try deploying again. This property indicates that your classes were already statically enhanced so that dynamic weaving should not occur. Since they weren't enhanced, lazy 1:1 and M:1 will default to eager.
这篇关于如何在EclipseLink中启用编织?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!