記述子の値(Project、TimeKeep、またはCostCenter。通常、これはサブクラスで実装されます。私が持っているものがあるかどうか疑問に思っています)に基づいて、他の3つのテーブルのいずれかで外部キーを指すことができる1つのフィールドを持つテーブルがあります。サブクラス名は親クラスと同じであり、noteObjectプロパティはjava.lang.Objectタイプのインスタンス変数にマップされるため 、にキャストする限り、Project、TimeKeep、またはCostCenterオブジェクトのいずれかを受け入れる必要があります。正しいタイプです。休止状態でこれが可能になりますか?ありがとうございます。
<hibernate-mapping package="com.tlr.finance.mappings">
<class name="AdminNotes" table="admin_notes">
<id name="adminNoteId" column="admin_note_id" type="integer">
<generator class="identity" />
</id>
<discriminator column="note_type" type="string" />
<!-- make this property an enumerated type. It is the discriminator -->
<property name="adminNoteType" column="note_type" type="string" not-null="true" />
<property name="adminNote" column="note" type="string" not-null="true" />
<property name="adminNoteAdded" column="note_date" type="timestamp"
not-null="true" />
<subclass name="AdminNotes" discriminator-value="project" >
<many-to-one name="noteObject" column="object_id" class="PsData" /><!-- Project -->
</subclass>
<subclass name="AdminNotes" discriminator-value="user" >
<!-- rename timekeep to user -->
<many-to-one name="noteObject" column="object_id" class="Timekeep" /><!-- user -->
</subclass>
<subclass name="AdminNotes" discriminator-value="costCenter" >
<!-- rename timekeep to user -->
<many-to-one name="noteObject" column="object_id" class="CostCenter" /><!-- cost center -->
</subclass>
</class>
</hibernate-mapping>