關于使用Hibernate時,resources中配置文件(XXXX.properties)的相關設定
內(nèi)容涉及:
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.properties.hibernate.show_sql=true
spring.jpa.properties.hibernate.format_sql=true
1.spring.jpa.hibernate.ddl-auto
設定值如下:
// (默認值)不執(zhí)行任何操作。
none --No action will be performed.
// 只用于創(chuàng)建數(shù)據(jù)表
create-only --Database creation will be generated.
// 刪除數(shù)據(jù)表
drop --Database dropping will be generated.
// 將創(chuàng)建的數(shù)據(jù)表刪除然后再創(chuàng)建表
create --Database dropping will be generated followed by database creation.
// 在事務開啟時創(chuàng)建表,在事務結(jié)束時刪除表
create-drop --Drop the schema and recreate it on SessionFactory startup. Additionally, drop the schema on SessionFactory shutdown.
// 檢驗數(shù)據(jù)庫架構(gòu)
validate --Validate the database schema
// 更新數(shù)據(jù)庫架構(gòu)
update --Update the database schema
2.spring.jpa.properties.hibernate.show_sql
設定值如下:
// 默認值
false
// 將所有SQL語句寫入控制臺。
true --Write all SQL statements to the console. This is an alternative to setting the log category org.hibernate.SQL to debug.
3.spring.jpa.properties.hibernate.format_sql
設定值如下:
// 默認值
false
// 在日志和控制臺中格式化打印SQL語句
true --Pretty-print the SQL in the log and console.

github-pic