lqxue

          常用鏈接

          統(tǒng)計(jì)

          book

          tools

          最新評(píng)論

          為什么在hibernate中用list影射one-to-many時(shí),在查詢數(shù)據(jù)時(shí),經(jīng)常有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) 評(píng)論(1)  編輯  收藏

          評(píng)論

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

          哪位大神知道的,求指教!  回復(fù)  更多評(píng)論   


          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 金沙县| 南投县| 磐石市| 扶绥县| 乐亭县| 巴南区| 清远市| 江孜县| 名山县| 深泽县| 瓮安县| 桐梓县| 株洲市| 凌源市| 临夏县| 高唐县| 曲沃县| 高陵县| 项城市| 武功县| 孝义市| 靖江市| 平昌县| 集贤县| 隆德县| 葫芦岛市| 同心县| 晋中市| 佳木斯市| 甘肃省| 和政县| 达日县| 东丽区| 阳泉市| 鄂托克前旗| 资中县| 余姚市| 崇义县| 湖州市| 城市| 祥云县|