spring.jpa.hibernate.ddl-auto
首次程序运行时对ddl的操作
create
: 每次运行该程序,没有表格会新建表格,表内有数据会清空;create-drop
: 每次程序结束的时候会清空表update
: 每次运行程序,没有表格会新建表格,表内有数据不会清空,只会更新validate
:运行程序会校验数据与数据库的字段类型是否相同,不同会报错。none
: 禁用 ddl 处理
默认值:
当数据库是嵌入式数据库时,Spring Boot会指定该属性默认值为create-drop
;当不是嵌入式数据库时,Spring Boot指定该属性的默认值为none
。
spring.jpa.show-sql
是否输出sql语句,默认为false
spring.jpa.properties.hibernate.format_sql
是否格式化sql语句,默认false
spring.jpa.properties.hibernate.enable_lazy_load_no_trans
是否在没有事务的时候允许懒加载, 默认false
spring.jpa.open-in-view
延时加载的一些属性数据,可以在页面展现的时候,保持session不关闭,从而保证能在页面进行延时加载。默认true
spring.jpa.properties.hibernate.max_fetch_depth
为单向关联(一对一、多对一)的外连接抓取(Outer Join Fetch)树设置最大深度,值为0意味着将关闭默认的外连接抓取。建议在0到3之间取值
spring.jpa.properties.hibernate.hbm2ddl
自动创建、更新和验证数据表结构
create
:每次加载hibernate时都会删除上一次的生成的表,然后根据你的model类再重新来生成新表create-drop
:每次加载hibernate时根据model类生成表,但是sessionFactory一关闭,表就自动删除。update
:第一次加载hibernate时根据model类会自动建立起表的结构(前提是先建立好数据库),
以后加载hibernate时根据 model类自动更新表结构,即使表结构改变了但表中的行仍然存在不会删除以前的行。validate
:每次加载hibernate时,验证创建数据库表结构,只会和数据库中的表进行比较,不会创建新表,但是会插入新值。
spring.jpa.properties.hibernate.dialect
连接数据库使用的SQL方言
logging.level.org.hibernate.type.descriptor.sql.BasicBinder
spring.jpa.properties.hibernate.use_sql_comments
是否在SQL语句中输出便于调试的注释信息,默认值为false
spring.jpa.properties.hibernate.jdbc.fetch_size
为Hibernate关联的批量抓取设置默认数量。
spring.jpa.properties.hibernate.order_updates
强制Hibernate按照被更新数据的主键为SQL更新排序。这么做将减少在高并发系统中事务的死锁。值为true
或false