hibernate.hbm2ddl.auto 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自動更新數據庫結構 以上4個屬性對同一配置文件下所用有的映射表都起做用 總結: 1.請慎重使用此參數,不必就不要隨便用。 2.若是發現數據庫表丟失,請檢查hibernate.hbm2ddl.auto的配置.