Eclipselink:不支持的操作:[instantiateForUnitOfWorkValueHolder]
Eclipselink : Operation not supported: [instantiateForUnitOfWorkValueHolder]
当我尝试访问实体中存在的方法中延迟加载的@oneToMany 关系属性时,出现以下错误。
错误:
Caused by: Exception [EclipseLink-7097] (Eclipse Persistence Services - 2.6.3.v20160428-59c81c5): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Operation not supported: [instantiateForUnitOfWorkValueHolder].
at org.eclipse.persistence.exceptions.ValidationException.operationNotSupported(ValidationException.java:1496)
at org.eclipse.persistence.internal.indirection.ProtectedValueHolder.instantiateForUnitOfWorkValueHolder(ProtectedValueHolder.java:61)
at org.eclipse.persistence.internal.indirection.UnitOfWorkValueHolder.instantiateImpl(UnitOfWorkValueHolder.java:160)
at org.eclipse.persistence.internal.indirection.UnitOfWorkValueHolder.instantiate(UnitOfWorkValueHolder.java:234)
at org.eclipse.persistence.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:89)
at org.eclipse.persistence.indirection.IndirectList.buildDelegate(IndirectList.java:271)
at org.eclipse.persistence.indirection.IndirectList.getDelegate(IndirectList.java:455)
at org.eclipse.persistence.indirection.IndirectList.<init>(IndirectList.java:597)
at org.eclipse.persistence.indirection.IndirectList.listIterator(IndirectList.java:596)
at org.eclipse.persistence.indirection.IndirectList.iterator(IndirectList.java:555)
at com.order.modelGroupBase.getStatus(GroupBase.java:205)
实体:
@Entity
@Table(name="GROUP")
@Customizer(GroupBaseCustomizer.class)
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@ClassExtractor(GroupClassExtractor.class)
@InstantiationCopyPolicy
@Cacheable
@Cache( alwaysRefresh=true,
refreshOnlyIfNewer=true,
expiry=300000,
coordinationType = CacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES)
public class GroupBase {
@OneToMany(cascade=CascadeType.ALL, mappedBy="groupBase", targetEntity=Groups.class)
@PrivateOwned
private List groups = new ArrayList<>();
public OrderGroupStatus getStatus() {
//error is at this line when I try to iterate..
for (Iterator itr = getGroups().iterator(); itr.hasNext();) {
Groups relationship = (Groups) itr.next();
//some operation..
}
}
}
我在 eclipselink 论坛上看过,但他们没有明确解决这个问题,一些链接说它与我的应用程序中的 weaving.But 有关,我根本没有启用编织,我也没有不打算做。
此代码在没有 JPA 的 Eclipselink 2.3.2 上运行良好。现在,我将 Eclipselink 2.6.3 与 JPA 2.0 和 IBM Websphere 8.5.5.8 一起使用。
注意:这个问题不是每次都会随机发生,而且我观察到每次创建新对象时都会发生。
经过多次尝试并更正我的延迟加载设置后,我发现在其他实体的同一实体上使用不同的 fetchType 可能会在 SHARED_CACHE 模式下导致此问题。
@OneToMany(cascade=CascadeType.ALL, mappedBy="groupBase", targetEntity=Groups.class)
@PrivateOwned
private List groups = new ArrayList<>();
默认情况下,@OneToMany 是延迟获取的,但在同一实体的另一个实体中 'Groups' 我已将 fetchType 配置为 EAGER。
当我将两种提取类型都设置为 LAZY 时,此错误不再发生。
当我尝试访问实体中存在的方法中延迟加载的@oneToMany 关系属性时,出现以下错误。
错误:
Caused by: Exception [EclipseLink-7097] (Eclipse Persistence Services - 2.6.3.v20160428-59c81c5): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Operation not supported: [instantiateForUnitOfWorkValueHolder].
at org.eclipse.persistence.exceptions.ValidationException.operationNotSupported(ValidationException.java:1496)
at org.eclipse.persistence.internal.indirection.ProtectedValueHolder.instantiateForUnitOfWorkValueHolder(ProtectedValueHolder.java:61)
at org.eclipse.persistence.internal.indirection.UnitOfWorkValueHolder.instantiateImpl(UnitOfWorkValueHolder.java:160)
at org.eclipse.persistence.internal.indirection.UnitOfWorkValueHolder.instantiate(UnitOfWorkValueHolder.java:234)
at org.eclipse.persistence.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:89)
at org.eclipse.persistence.indirection.IndirectList.buildDelegate(IndirectList.java:271)
at org.eclipse.persistence.indirection.IndirectList.getDelegate(IndirectList.java:455)
at org.eclipse.persistence.indirection.IndirectList.<init>(IndirectList.java:597)
at org.eclipse.persistence.indirection.IndirectList.listIterator(IndirectList.java:596)
at org.eclipse.persistence.indirection.IndirectList.iterator(IndirectList.java:555)
at com.order.modelGroupBase.getStatus(GroupBase.java:205)
实体:
@Entity
@Table(name="GROUP")
@Customizer(GroupBaseCustomizer.class)
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@ClassExtractor(GroupClassExtractor.class)
@InstantiationCopyPolicy
@Cacheable
@Cache( alwaysRefresh=true,
refreshOnlyIfNewer=true,
expiry=300000,
coordinationType = CacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES)
public class GroupBase {
@OneToMany(cascade=CascadeType.ALL, mappedBy="groupBase", targetEntity=Groups.class)
@PrivateOwned
private List groups = new ArrayList<>();
public OrderGroupStatus getStatus() {
//error is at this line when I try to iterate..
for (Iterator itr = getGroups().iterator(); itr.hasNext();) {
Groups relationship = (Groups) itr.next();
//some operation..
}
}
}
我在 eclipselink 论坛上看过,但他们没有明确解决这个问题,一些链接说它与我的应用程序中的 weaving.But 有关,我根本没有启用编织,我也没有不打算做。
此代码在没有 JPA 的 Eclipselink 2.3.2 上运行良好。现在,我将 Eclipselink 2.6.3 与 JPA 2.0 和 IBM Websphere 8.5.5.8 一起使用。
注意:这个问题不是每次都会随机发生,而且我观察到每次创建新对象时都会发生。
经过多次尝试并更正我的延迟加载设置后,我发现在其他实体的同一实体上使用不同的 fetchType 可能会在 SHARED_CACHE 模式下导致此问题。
@OneToMany(cascade=CascadeType.ALL, mappedBy="groupBase", targetEntity=Groups.class)
@PrivateOwned
private List groups = new ArrayList<>();
默认情况下,@OneToMany 是延迟获取的,但在同一实体的另一个实体中 'Groups' 我已将 fetchType 配置为 EAGER。
当我将两种提取类型都设置为 LAZY 时,此错误不再发生。