寫程序,做產品,過日子

          成功其實很簡單,就是強迫自己堅持下去

          BlogJava 首頁 新隨筆 聯系 聚合 管理
            69 Posts :: 1 Stories :: 92 Comments :: 0 Trackbacks

          1. Hibernate can not set null value to primitive types.
          If data is null in DB, and Hibernate maps it as primitive type, An PropertyAccessException will be th rowed when.
          Our solution (Discussed with Andy):
          1) Ensure all Database fileds have default value.
          2) Wrap all primitive value in DTO. (Andy says this is not essential.)

          2. Debug Hibernate in my product

          In single way one-to-many association, when update, Hibernate always update children's id to null!
          Only when Bi-one-to-many association, Hibernate can update children correctly.
          Do not use Hibernate List. It need a index/list-index property, which bind to a DB column, but means the real index of Java List. The List often get many null items.
          Hibernate set is good. But our DTO already use ArrayList as Collection.
          Children Id is missing after updated it.
          Hibernate session.save normally call insert, session.update normally call update.
          When update Bi-one-to-many association, parent always correct. But always insert children, can not delete and update children. CAUSE: I use a modifiable field as PK, because all children's ID is missing from JSP. In this case, I should manual delete and insert children table.

          BTW, Set can not include duplicated items. However. Our DTO have no PK when it created until saved it to DB. This cause add new item fail.


          Technorati : ,

          posted on 2006-11-06 16:59 Welkin Hu 閱讀(213) 評論(0)  編輯  收藏 所屬分類: Java
          主站蜘蛛池模板: 鹤山市| 阳江市| 丽水市| 曲松县| 金堂县| 中阳县| 仁布县| 荥阳市| 池州市| 百色市| 洛川县| 米泉市| 印江| 门头沟区| 松溪县| 嘉祥县| 永川市| 梁平县| 鹤壁市| 梁山县| 宣武区| 吉隆县| 溆浦县| 浮梁县| 望奎县| 墨脱县| 依安县| 昭平县| 河曲县| 东平县| 本溪| 德保县| 永寿县| 静安区| 寿光市| 上蔡县| 望城县| 定结县| 璧山县| 湖南省| 舞阳县|