【JPA】关于使用Hibernate时,resources中配置文件(XXXX.properties)的相关设定

关于使用Hibernate时,resources中配置文件(XXXX.properties)的相关设定

内容涉及:

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

设定值如下:

// (默认值)不执行任何操作。
none        --No action will be performed.
// 只用于创建数据表
create-only --Database creation will be generated.
// 删除数据表
drop        --Database dropping will be generated.
// 将创建的数据表删除然后再创建表
create      --Database dropping will be generated followed by database creation.
// 在事务开启时创建表,在事务结束时删除表
create-drop --Drop the schema and recreate it on SessionFactory startup. Additionally, drop the schema on SessionFactory shutdown.
// 检验数据库架构
validate    --Validate the database schema
// 更新数据库架构
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官方文档参照

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容