我在使用 Eclipselink 2.2.0 映射继承时遇到问题。这是我的抽象实体:
@Entity
@Inheritance(strategy= InheritanceType.SINGLE_TABLE)
public abstract class Feature extends TenantPossession {
private FeatureType featureType;
@Enumerated(EnumType.STRING)
public FeatureType getFeatureType() {
return featureType;
}
public void setFeatureType(FeatureType featureType) {
this.featureType = featureType;
}
}
子类如下所示:
@Entity
public class RecordingFeature extends Feature {
// here some attributes
}
当我第一次保存该功能时,它工作正常。但是当我尝试设置特征类型并保存它时,什么也没有发生。
Feature feature = new RecordingFeature();
feature.setType(FeatureType.RECORDING);
feature = featureService.save(feature); // works fine
...提交交易并开始另一笔交易...
feature.setType(FeatureType.UNKNOWN);
feature = featureService.save(feature); // seems to work, but type is not set in DB
跟继承有关系吗?我在没有继承的代码中还有其他情况可以正常工作。