lqxue

          常用鏈接

          統(tǒng)計

          book

          tools

          最新評論

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

          評論

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

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


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


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 江阴市| 雅安市| 巴林左旗| 松江区| 平陆县| 荆门市| 文昌市| 泰州市| 思南县| 黔南| 克东县| 仁寿县| 淄博市| 中方县| 汕头市| 霍邱县| 芜湖市| 马龙县| 广汉市| 嘉祥县| 松阳县| 沭阳县| 施秉县| 巴林右旗| 麻栗坡县| 烟台市| 麟游县| 辽阳市| 平塘县| 古交市| 新余市| 越西县| 阿克陶县| 五大连池市| 德保县| 十堰市| 汝城县| 百色市| 阳东县| 大新县| 海林市|