Eclipselink2.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
継承と関係がありますか?継承のないコードで、正常に機能する別のケースがあります。