首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >SpringDataJPA笔记(2)-基于SpringBoot的配置项

SpringDataJPA笔记(2)-基于SpringBoot的配置项

作者头像
yingzi_code
发布2019-08-31 12:25:21
发布2019-08-31 12:25:21
1.6K0
举报

基于SpringBoot的配置项

大概整理了一下

配置项

说明

spring.jpa.database

spring.jpa.database-platform

设置数据库引擎

spring.jpa.generate-ddl

如果Hibernate自动配置被激活,那该标识就不会被使用,因为ddl-auto设置粒度更细

spring.jpa.hibernate.ddl-auto

create----每次运行该程序,没有表格会新建表格,表内有数据会清空 create-drop----每次程序结束的时候会清空表update----每次运行程序,没有表格会新建表格,表内有数据不会清空,只会更新validate----运行程序会校验数据与数据库的字段类型是否相同,不同会报错

spring.jpa.hibernate.naming.implicit-strategy

逻辑名称命名策略,JPA的命名策略默认是将实体类的属性aaaBbCc转换成aaa_bb_cc,添加如下策略则不做转换org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl

spring.jpa.hibernate.naming.physical-strategy

物理名称命名策略

spring.jpa.hibernate.use-new-id-generator-mappings

是否使用Hibernate的主键生成策略

spring.jpa.mapping-resources

spring.jpa.open-in-view

该配置会注册一个OpenEntityManagerInViewInterceptor。在处理请求时,将 EntityManager 绑定到整个处理流程中(model->dao->service->controller),开启和关闭session。这样一来,就不会出现 no Session 的错误了(可以尝试将该配置的值置为 false, 就会出现懒加载的错误了

spring.data.jpa.repositories.bootstrap-mode

Bootstrap mode for JPA repositories

spring.data.jpa.repositories.enabled

Whether to enable JPA repositories

spring.jpa.show-sql

打印sql语句,方便调试

spring.jpa.properties.*

jpa provider的配置项

spring.jpa.properties.hibernate.format-sql

是否格式化输出字符串,增强SQL的可读性

spring.jpa.properties.javax.persistence.sharedCache.mode

配置shared-cache-mode

spring.jpa.properties.hibernate.cache.region.factory_class

指定缓存provider

spring.jpa.properties.hibernate.generate_statistics

打开hibernate统计信息

spring.jpa.properties.hibernate.cache.use_second_level_cache

打开二级缓存

spring.jpa.properties.hibernate.cache.use_query_cache

打开查询缓存

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019年05月05日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档