bow*_*sie 7 java many-to-many hibernate jpa sql-order-by
我有一个@ManyToMany映射,其中表通过映射表自引用,我们想要在实际映射表中对订单ID进行排序,但发现很难配置它.
我们可以在hibernate xml中执行它,所以很自然地假设JPA注释中有支持.有人知道我们如何对映射表中的值进行排序吗?
该表是:
wap_site_components
intid
strname
intcomponentdef
dtmcreated      
intcustomer 
以及自引用的映射表是:
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)
在Hibernate Annotations中我们有:
@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;
}
这是我们在hibernate 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),但这对我们来说没有用)
| 归档时间: | 
 | 
| 查看次数: | 3532 次 | 
| 最近记录: |