【JPA】關于使用Hibernate時,resources中配置文件(XXXX.properties)的相關設定

關于使用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

hibernate官方文檔參照

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容