zzeng

          zzeng

          My Links

          Blog Stats

          常用鏈接

          留言簿(2)

          隨筆檔案

          文章檔案

          收藏夾

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          Hibernate取得Select的值

          http://www.hibernate.org/hib_docs/reference/zh-cn/html/queryhql.html#queryhql-select

          查詢可以返回任何值類型的函數,

          select子句選擇在結果集中返回哪些對象和屬性。思考一下下面的例子:

          select mate 
          from eg.Cat as cat
          inner join cat.mate as mate

          這個查詢會選擇出作為其它貓(Cat)朋友(mate)的那些貓。當然,你可以更加直接的寫成下面的形式:

          select cat.mate from eg.Cat cat

          你甚至可以選擇集合元素,使用特殊的elements功能。下面的查詢返回所有貓的小貓。

          select elements(cat.kittens) from eg.Cat cat

          查詢可以返回任何值類型的屬性,包括組件類型的屬性:

          select cat.name from eg.DomesticCat cat
          where cat.name like 'fri%'

          select cust.name.firstName from Customer as cust

          查詢可以用元素類型是Object[]的一個數組返回多個對象和/或多個屬性。

          select mother, offspr, mate.name 
          from eg.DomesticCat as mother
          inner join mother.mate as mate
          left outer join mother.kittens as offspr

          或者實際上是類型安全的Java對象

          select new Family(mother, mate, offspr)
          from eg.DomesticCat as mother
          join mother.mate as mate
          left join mother.kittens as offspr

          上面的代碼假定Family有一個合適的構造函數。


          posted on 2005-12-18 10:39 zzeng 閱讀(1549) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 阆中市| 姜堰市| 沙田区| 平度市| 德清县| 娄烦县| 连平县| 密云县| 拜泉县| 祁阳县| 宁城县| 缙云县| 罗江县| 乐亭县| 隆回县| 黄大仙区| 磐石市| 成都市| 渑池县| 贺兰县| 电白县| 象州县| 常德市| 齐齐哈尔市| 黄冈市| 东安县| 定襄县| 南皮县| 托克托县| 清涧县| 集安市| 改则县| 阳信县| 兴和县| 凤凰县| 莎车县| 芜湖市| 广东省| 炎陵县| 巧家县| 镇坪县|