私はすでにその仕事を得るために数時間を費やしています。履歴ポリシーを使用して、一部のテーブルの完全な履歴を作成しています。これは抽象クラスで定義されます。次に、このクラスを実装し、そのフィールドを定義する通常のエンティティがあります。そこで上位クラスから継承したクラスを使いたかったのですが、そのテーブルが履歴テーブルに設定されています。それは完全に機能しましたが、唯一の問題は、履歴化されたテーブル (lasso_warehandling_entry) に対してクエリを実行すると、常に履歴エンティティ (lasso_warehandling_entry_hist) から結果が返されることでした。そこで、descriptor.getInheritancePolicy().setShouldReadSubclasses(false); という行を追加しました。私はどこかで読んだ、それは私の問題を解決するはずです。残念ながらそうではありません。今、私は常に次のメッセージを受け取ります:
Exception Description: The descriptor [RelationalDescriptor(dao.LassoWarehandlingEntry --> [DatabaseTable(lasso_warehandling_entry)])] has been set to use inheritance, but a class indicator field has not been defined.
When using inheritance, a class indicator field or class extraction method must be set.
Parent Descriptor: [RelationalDescriptor(org.rorotec.lasso.dao.LassoWarehandlingEntry --> [DatabaseTable(lasso_warehandling_entry)])]
Descriptor: RelationalDescriptor(dao.LassoWarehandlingEntry --> [DatabaseTable(lasso_warehandling_entry)])
エンティティごとに個別のテーブルを使用するため、インジケーター フィールドを使用してもあまり意味がありません。とにかく、私はこのメッセージを取り除くことができません。誰も私がそれを解決する方法を知っていますか? コードは次のようになります。
@MappedSuperclass
@Customizer(abstractDao.HistoryCustomizer.class)
public abstract class AbstractAuditedOzlEntity {
// defined the columns all the autited classes have
...
}
public class HistoryCustomizer implements DescriptorCustomizer {
public void customize(ClassDescriptor descriptor) {
HistoryPolicy policy = new HistoryPolicy();
policy.addHistoryTableName(descriptor.getTableName() + "_hist");
policy.addStartFieldName("start_date");
policy.addEndFieldName("end_date");
descriptor.setHistoryPolicy(policy);
// This here I added afterwards, as described in the text, and is the reason for the error message i get
descriptor.getInheritancePolicy().setShouldReadSubclasses(false);
}
}
@Entity
// when i define the inhertiancetype already in the abstract class, it doesn't seem to have any influence, so I added it here.
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
@Table(name = "lasso_warehandling_entry")
public class LassoWarehandlingEntry extends AbstractAuditedOzlEntity implements Serializable {
// define the specific stuff of this table
...
}
@Entity
@Table(name = "lasso_warehandling_entry_hist")
@AttributeOverride(name="id", column=@Column(name="hist_id"))
public class LassoWarehandlingEntryHist extends LassoWarehandlingEntry {
...
// add the columns which only exist in the history tables like end_date
}