歡迎光臨郝學武的blog。

          hibernate的hibernate.hbm2ddl.auto屬性

          Posted on 2008-09-19 18:10 陜西BOY 閱讀(8038) 評論(2)  編輯  收藏

          前天做項目的時候表結構和數據總是在程序執行的時候無端的修改,折騰了好長時間,查了很長時間hibernate的數據庫映射文件和接口程序,始終沒有發現有什么錯誤,到最后才發現了它!
                     <property name="hibernate.hbm2ddl.auto" value="update" />
          解釋如下:

          hibernate.hbm2ddl.auto Automatically validate or export schema DDL to the database when the SessionFactory is created. With create-drop, the database schema will be dropped when the SessionFactory is closed explicitly.  eg. validate | update | create | create-drop

          其實這個參數的作用主要用于:自動創建|更新|驗證數據庫表結構。
          如果沒有此方面的需求建議set value="none".

          其它幾個參數的意思:

           validate               加載hibernate時,驗證創建數據庫表結構
           create                  每次加載hibernate,重新創建數據庫表結構
           create-drop        加載hibernate時創建,退出是刪除表結構
           update                 加載hibernate自動更新數據庫結構

          Feedback

          # re: hibernate的hibernate.hbm2ddl.auto屬性[未登錄]  回復  更多評論   

          2008-09-20 11:02 by
          你好 我是出版社的編輯,我看到你博客中的內容,感覺寫的非常好,如果想把這些內容和更多的人分享,可以和我聯系,把這些東西寫成書?,F在有一本Java數據庫編程的書。
          我的郵箱:books_522008@yahoo.com.cn

          # re: hibernate的hibernate.hbm2ddl.auto屬性[未登錄]  回復  更多評論   

          2014-05-04 16:43 by 啊啊
          啊啊

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


          網站導航:
           

          posts - 17, comments - 65, trackbacks - 0, articles - 28

          Copyright © 陜西BOY

          主站蜘蛛池模板: 康平县| 海林市| 女性| 厦门市| 雷波县| 伊宁县| 宁晋县| 金乡县| 张家口市| 将乐县| 平南县| 白水县| 红桥区| 陆良县| 崇州市| 孟州市| 平南县| 瑞安市| 佛学| 贵州省| 安吉县| 阿合奇县| 林周县| 潜山县| 威信县| 额济纳旗| 江口县| 巨鹿县| 铜陵市| 宜川县| 营口市| 南郑县| 和田县| 太和县| 岳池县| 呈贡县| 林芝县| 西充县| 靖边县| 福泉市| 南岸区|