Hibernate一個配置參數hibernate.hbm2ddl.auto

來源:互聯網
上載者:User
<properties>
           <property name="hibernate.show_sql" value="true" />      
           <property name="hibernate.hbm2ddl.auto" value="create" />
</properties>

Hibernate的參數配置,解釋如下:
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自動更新資料庫結構

總結:

1.請謹慎使用此參數,沒必要就不要隨便用。

2.如果探索資料庫表丟失,請檢查hibernate.hbm2ddl.auto的配置 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.