マッピングテーブルを介してテーブルが自己参照する@ManyToManyマッピングがありますが、実際のマッピングテーブルのオーダーIDで注文したいが、これを設定するのは難しい。Hibernateでテーブル値をマッピングすることによる順序付け
JPAアノテーションにサポートがあると仮定すると、それはハイバネートXMLで実行できます。マッピングテーブルの値をどのように注文するかは誰にも分かりますか?
表は以下のとおりです。
wap_site_components
intid
strname
intcomponentdef
dtmcreated
intcustomer
とマッピングテーブルの自己参照があること:私たちが持っているHibernateの注釈で
wap_site_component_relations
intid
intparent (references intid in wap_site_components)
intchild (references intid in wap_site_components)
intorder (this is the value we want to order the collection on)
:
@ManyToMany (fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinTable (name = "wap_site_component_relations",
joinColumns = {@JoinColumn (name = "intparent", referencedColumnName = "id") },
inverseJoinColumns = {@JoinColumn (name = "intchild", referencedColumnName = "id") })
public Set<WapComponent> getChildren() {
return children;
}
これは、我々が行ってどのようですそれは冬眠中のxml:
<set
name="children"
table="wap_site_component_relations"
lazy="true"
cascade="none"
sort="unsorted"
order-by="intorder"
mutable="false"
>
<cache
usage="read-only"
/>
<key
column="intparent"
>
</key>
<many-to-many
class="se.plusfoursix.im46.data.wap.WapComponent"
column="intchild"
outer-join="auto"
/>
</set>
@OrderByタグを使用しますが、マッピングテーブルのintorder値を参照することはできません。何か案は?ありがとう。
(私たちは、コード内で子どもたちのコレクションを@OrderBy(intorder)を試してみましたが、それが私たちのために働いていない)
で行うことができます。 – bowsie