Eclipselink 2.6.3 with JPA 2.0
我对SINGLE_TABLE继承策略有一个问题,因为你可以看到我有一个由Z&扩展的A类。 X.当我查询并获取Z或X实体列表并尝试更改某些内容并逐个更新时,在我调用 em.merge()获取合并克隆对象的过程中,它给出了后退A级很奇怪。
因为我已经有类提取器,它根据特定的字段值决定应该返回什么类。
此问题是间歇性的,无法每次都复制,我也在UnitOfWorkImpl方法中进行了调试
public Object mergeCloneWithReferences(Object rmiClone, MergeManager manager) {
if (rmiClone == null) {
return null;
}
//this line should always give correct entity back.. but doesnt happen why ?
ClassDescriptor descriptor = getDescriptor(rmiClone);
if ((descriptor == null) || descriptor.isDescriptorTypeAggregate()) {
if (manager.getCascadePolicy() == MergeManager.CASCADE_BY_MAPPING){
throw new IllegalArgumentException(ExceptionLocalization.buildMessage("not_an_entity", new Object[]{rmiClone}));
}
return rmiClone;
}
//CR#2272
logDebugMessage(rmiClone, "merge_clone_with_references");
ObjectBuilder builder = descriptor.getObjectBuilder();
Object implementation = builder.unwrapObject(rmiClone, this);
Object mergedObject = manager.mergeChanges(implementation, null, this);
if (isSmartMerge()) {
return builder.wrapObject(mergedObject, this);
} else {
return mergedObject;
}
}
有人可以指出出了什么问题吗?
A类
@Entity
@Table(name="TABLE_A")
@Customizer(ACustomizer.class)
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@ClassExtractor(AExtractor.class)
@InstantiationCopyPolicy
@Cacheable
@Cache( alwaysRefresh=true,
refreshOnlyIfNewer=true,
expiry=300000,
coordinationType = CacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES)
public class A implements Serializable {
@Column(name="ABC")
private String abc;
//某些字段
}
Z级
@Entity
@Customizer(ZCustomizer.class)
public class Z extends A{
//some fields
}
第X类
@Entity
public class X extends A{
//some fields
}