寫程序,做產品,過日子

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

          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 閱讀(217) 評論(0)  編輯  收藏 所屬分類: Java
          主站蜘蛛池模板: 新昌县| 兴安县| 深圳市| 旅游| 石嘴山市| 林州市| 银川市| 高碑店市| 景洪市| 兰坪| 荃湾区| 平湖市| 灵璧县| 松江区| 文水县| 明溪县| 赤壁市| 文昌市| 靖边县| 达州市| 南宁市| 开封市| 方正县| 屯门区| 衡山县| 井冈山市| 辽阳县| 普格县| 郓城县| 乐亭县| 柘城县| 西宁市| 太和县| 洞口县| 元朗区| 临城县| 东乌珠穆沁旗| 尉犁县| 新河县| 木兰县| 沁阳市|