在部署具有延迟获取实体的应用程序时,我在 GlassFish 终端上收到以下警告,
警告:恢复实体类的
OneToOne
orManyToOne
属性的惰性设置, 因为编织未启用或未发生。[zoneTable]
[class entity.ZoneCharge]
对于项目中列出的任何实体。
我的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="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 也可以使用延迟获取,但我认为,由于上述警告,它被认为是急切的。
如何启用编织(或其他方式)以避免此警告?
当我输入这里提到的这个命令时,
java org.eclipse.persistence.tools.weaving.jpa.StaticWeave
在命令行上,我收到以下错误。
错误:无法找到或加载主类org.eclipse.persistence.tools.weaving.jpa.StaticWeave
有什么方法可以克服这个警告?