mssqlの制限が900バイトであるため、インデックスサイズを小さくする必要があります。hibernateコレクションのインデックスサイズを減らすにはどうすればいいですか(composite-elementで設定)?
私は、セットとして宣言されたコレクションを持つクラスを持っています。このため、主キーは外部キーを含むすべてのnotnull列で構成されます。この主キーから索引が作成されます。インデックスをこれらの列すべてに渡す必要はありません。
データ構造全体の設定を変更せずにインデックスサイズを減らす方法はありますか?ここで
周囲のクラス定義の内部コレクションの現在の設定です:
<set cascade="save-update,persist,merge,refresh,replicate,evict,delete,delete-orphan" fetch="select" lazy="true" table="mySubsetTable" batch-size="1000" name="attributes">
<key foreign-key="FK_Mothertable">
<column name="number"/>
<column name="data"/>
</key>
<composite-element class="MySubsetElement">
<property name="type" length="200" not-null="true" type="class"/>
<property name="attribute" length="2000" column="attrValue" not-null="false"/>
<property name="myboolean" type="boolean">
<column name="myboolean"/>
</property>
<property name="anotherAttribute" length="200"/>
<property name="evenAnotherAttribute" length="200" not-null="true"/>
<property name="evenOneMoreAttribute" not-null="true">
<type name="SomeClass">
<param name="enumClass">someEnumClass</param>
</type>
</property>
</composite-element>
</set>
私は現在、XDocletの注釈と3.3.1を休止状態使用しています:あなたのための
/**
* Attributes of this matchable
*
* @hibernate.set table="mySubsetTable" cascade="save-update,persist,merge,refresh,replicate,evict,delete,delete-orphan" lazy="true"
* batch-size="1000" fetch="select"
* @hibernate.key foreign-key="FK_Mothertable"
* @hibernate.key-column name="number"
* @hibernate.key-column name="data"
* @hibernate.composite-element class="MySubsetElement"
*/
public Set<MySubsetElement> getSubsetElements() { ... }
おかげで多くのことを提案!
(そして、私はすでにこれを見つけたhttp://docs.jboss.org/hibernate/に私を参照しないでください。)
EDIT 私は、サイズ制限に合わせて、すべてのプロパティのサイズを小さくすることはできません。外部キーで構成されるインデックスで十分です。 また、私は既に使用されている製品に取り組んでいるので、基礎となるデータ構造を変更しないソリューションが本当に好きです。
あなたは '複合要素 'を使用しています。それは必要ですか? 「MySubsetElement」の「ファーストクラスの市民」エンティティを作成し、通常のOneToMany関係を使用するのはどうですか? – JimmyB
私はここで巨大な構造を持っていて、いつか私の前に来た誰かがそれをそのように定義しました...これとは別のやり方があるなら、私はここにそれを入れて、私の場合に適用できるならば後で評価します。あなたの提案をありがとう! –
これは、「MySubset」をエンティティとして構成し、セット内に一対多の関係を作成するということですか? –