歡迎光臨郝學(xué)武的blog。

          hibernate的hibernate.hbm2ddl.auto屬性

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

          前天做項(xiàng)目的時(shí)候表結(jié)構(gòu)和數(shù)據(jù)總是在程序執(zhí)行的時(shí)候無端的修改,折騰了好長時(shí)間,查了很長時(shí)間hibernate的數(shù)據(jù)庫映射文件和接口程序,始終沒有發(fā)現(xiàn)有什么錯(cuò)誤,到最后才發(fā)現(xiàn)了它!
                     <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

          其實(shí)這個(gè)參數(shù)的作用主要用于:自動(dòng)創(chuàng)建|更新|驗(yàn)證數(shù)據(jù)庫表結(jié)構(gòu)。
          如果沒有此方面的需求建議set value="none".

          其它幾個(gè)參數(shù)的意思:

           validate               加載hibernate時(shí),驗(yàn)證創(chuàng)建數(shù)據(jù)庫表結(jié)構(gòu)
           create                  每次加載hibernate,重新創(chuàng)建數(shù)據(jù)庫表結(jié)構(gòu)
           create-drop        加載hibernate時(shí)創(chuàng)建,退出是刪除表結(jié)構(gòu)
           update                 加載hibernate自動(dòng)更新數(shù)據(jù)庫結(jié)構(gòu)

          Feedback

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

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

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

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

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


          網(wǎng)站導(dǎo)航:
           

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

          Copyright © 陜西BOY

          主站蜘蛛池模板: 方正县| 黄陵县| 陕西省| 察隅县| 江都市| 定南县| 高密市| 浦江县| 胶州市| 会同县| 新干县| 大石桥市| 民丰县| 隆安县| 文安县| 甘德县| 靖江市| 茶陵县| 昆山市| 合川市| 梁河县| 平陆县| 南京市| 塘沽区| 屯留县| 井冈山市| 全州县| 峨眉山市| 临夏市| 江城| 平凉市| 柞水县| 邻水| 开封市| 海盐县| 天气| 亚东县| 会昌县| 阳城县| 白朗县| 寿宁县|