欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
6.1.6 Sorted and ordered collections (2) - ordered on database side
Alternatively, instead of switching to the Sorted* interfaces (and the Tree*
implementations), you may want to work with a linked map and to sort elements
on the database side, not in memory. Keep the Map/HashMap declaration in the
Java class, and create the following mapping:
<map name="images" table="ITEM_IMAGE" order-by="IMAGENAME asc">
      <key column="ITEM_ID"/>
      <map-key column="IMAGENAME" type="string"/>
      <element type="string" column="FILENAME" not-null="true"/>
</map>
The expression in the order-by attribute is a fragment of an SQL order by
clause. In this case, Hibernate orders the collection elements by the IMAGENAME
column in ascending order during loading of the collection. You can even include
an SQL function call in the order-by attribute:
<map name="images" table="ITEM_IMAGE" order-by="lower(FILENAME) asc">
      <key column="ITEM_ID"/>
      <map-key column="IMAGENAME" type="string"/>
      <element type="string" column="FILENAME" not-null="true"/>
</map>
You can order by any column of the collection table. Internally, Hibernate uses a
LinkedHashMap, a variation of a map that preserves the insertion order of key elements.
In other words, the order that Hibernate uses to add the elements to the
collection, during loading of the collection, is the iteration order you see in your
application. The same can be done with a set: Hibernate internally uses a
LinkedHashSet. In your Java class, the property is a regular Set/HashSet, but
Hibernate’s internal wrapping with a LinkedHashSet is again enabled with the
order-by attribute:
<set name="images"   table="ITEM_IMAGE"   order-by="FILENAME asc">
      <key column="ITEM_ID"/>
      <element type="string" column="FILENAME" not-null="true"/>
</set>
You can also let Hibernate order the elements of a bag for you during collection
loading. Your Java collection property is either Collection/ArrayList or List/
ArrayList. Internally, Hibernate uses an ArrayList to implement a bag that preserves
insertion-iteration order:
<idbag name="images"   table="ITEM_IMAGE"   order-by="ITEM_IMAGE_ID desc">
      <collection-id type="long" column="ITEM_IMAGE_ID">
            <generator class="sequence"/>
      </collection-id>
      <key column="ITEM_ID"/>
      <element type="string" column="FILENAME" not-null="true"/>
</idbag>
The linked collections Hibernate uses internally for sets and maps are available
only in JDK 1.4 or later; older JDKs don’t come with a LinkedHashMap and
LinkedHashSet. Ordered bags are available in all JDK versions; internally, an
ArrayList is used.
In a real system, it’s likely that you’ll need to keep more than just the image
name and filename. You’ll probably need to create an Image class for this extra
information. This is the perfect use case for a collection of components.
 
Map/HashMap ->LinkedHashMap,
Set/HashSet      ->LinkedHashSet.
本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
Hibernate入門(mén)之Set與Map的排序
Hibernate中的column別和數據庫中的關(guān)鍵字一樣
EHCache 單獨使用
簡(jiǎn)單的在Java中使用SQLite的教程
SQL Server 數據庫基礎編程
CCTV(大褲衩)結構設計全程記錄(pic+text)
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久