lqxue

          常用鏈接

          統計

          book

          tools

          最新評論

          為什么在hibernate中用list影射one-to-many時,在查詢數據時,經常有null值

           Learned a little this weekend - Bag vs List in Hibernate.  I was troubled since i really wanted to have a Java ArrayList in my object so i could index in my jsp and iterate over the list in an update form.  Using a Hibernate Set left me unable to index.  A Hibernate List left the Java ArrayList populated using the primary key - if the keys were 0,1,2,... that would have been ok.  But i only needed a few items from the database in my ArrayList and since the Hibernate List maintains the position of the object in the ArrayList equal to the position in the database the technique was leaving holes in my ArrayList of nulls.  Of course this was not what i wanted.  Now this may be explained in the documentation but after reading it twice i did not fully understand the Hibernate List.  Over the weekend i read the book Hibernate in Action and discovered the Hibernate Bag and it solved my problem.  I can use a Java ArrayList that is loaded simply by adding new objects to the beginning of the ArrayList.

          posted on 2007-04-05 16:50 lqx 閱讀(3067) 評論(1)  編輯  收藏

          評論

          # re: 為什么在hibernate中用list影射one-to-many時,在查詢數據時,經常有null值 2015-06-15 18:53 游客

          哪位大神知道的,求指教!  回復  更多評論   


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


          網站導航:
           
          主站蜘蛛池模板: 图们市| 喜德县| 溧水县| 宁安市| 信阳市| 周宁县| 博白县| 阳春市| 洛宁县| 日照市| 阳信县| 乌拉特前旗| 六盘水市| 益阳市| 阳曲县| 乌兰察布市| 台东市| 遵义县| 繁昌县| 长武县| 金华市| 长阳| 绩溪县| 兴业县| 大宁县| 湖州市| 自治县| 农安县| 上饶县| 清远市| 绥德县| 朝阳市| 临武县| 张家界市| 嘉黎县| 合川市| 邹城市| 定陶县| 阜新市| 岳普湖县| 和硕县|