歡迎您光臨本站 註冊首頁

Hibernate自動根據映射創建資料庫表

←手機掃碼閱讀     火星人 @ 2014-03-09 , reply:0

  方案一

  在hibernate.cfg.xml中添加:

  1 <properties>

  2 <property name="hibernate.hbm2ddl.auto" value="create" />

  3 </properties>

  value的值可選項如下:

  1 * validate 載入hibernate時,驗證創建資料庫表結構

  2 * create 每次載入hibernate,重新創建資料庫表結構.

  3 * create-drop 載入hibernate時創建,退出是刪除表結構

  4 * update 載入hibernate自動更新資料庫結構

  方案二

  用自動生成代碼后,在/src下面有一個jdbc.properties文件,這裡加一句hibernate.hbm2ddl.auto=update.值的可選項同上.


[火星人 ] Hibernate自動根據映射創建資料庫表已經有1090次圍觀

http://coctec.com/docs/java/show-post-60255.html