Spring jpa配置 autoRegisterUserTypes

14 篇文章 0 订阅
5 篇文章 0 订阅
#用于自动注册最常用的类型。这意味着对于任何自动注册的类型,您都不需要提供类型注释。
spring.jpa.properties.jadira.usertype.autoRegisterUserTypes=true

#每次运行程序,没有表格会新建表格,表内有数据不会清空,只会更新
spring.jpa.hibernate.ddl-auto=update

#hibernate方言。mysql数据库使用
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect

#spring.jpa.generate-ddl是更高层次上的抽象,他和具体的JPA实现无关,spring.jpa.hibernate.ddl-auto是和Hibernate相关的更具体的设置。前者会影响到后者,最好不要两者混用,容易混淆。在实践中,直接用后者就行。
#如果你非得使用spring.jpa.generate-ddl,或者你看到别人用了他,那么你需要搞清楚:他的默认值是false,如果你显式设置为true,最后框架会选择update方式(从HibernateJpaVendorAdapter的源码可以看出)。

#如果两个属性都没有配置,那么系统会判断你使用的是不是内置数据库(hsqldb, h2, derby),如果是的话会选用create-drop策略,其他情况是none策略。
spring.jpa.hibernate.generate-ddl=true

#在事务外也可以访问懒加载的数据	https://blog.csdn.net/asdfsadfasdfsa/article/details/86520496
spring.jpa.hibernate.open-in-view=true

官网原文
Jadira provides Global Configuration options that can reduce the verbosity of your mapping. For example:

<persistence-unit …>

	...
	
	<!-- Integrator and globalised configuration functionality  -->
				
	<property name="jadira.usertype.autoRegisterUserTypes" value="true" />
	<property name="jadira.usertype.javaZone" value="UTC" />
			
</properties>

These are configured as JPA properties or Hibernate properties. ‘jadira.usertype.javaZone’ provides defaults for Java (presentation) timezones, saving you from needing to specify these as parameters on your usertypes. ‘jadira.usertype.currencyCode’ can be used to specify the default currency code to use when persisting unqualified monetary values. ‘jadira.usertype.seed’ can be used to specify a Hibernate Seed to be used for generating Timestamps used for versioning. Jadira provides two implementations of a seed - DbTimestampSeed which acquires the value from the database and JvmTimestampSeed which uses the local JVM. These types address zoning differences correctly. ‘jadira.usertype.autoRegisterUserTypes’ is used to autoregister the most commonly used types. This means for any of the autoregistered types you do not need to supply a type annotation. For the full list of supported types, review the subclasses of ‘AbstractUserTypeHibernateIntegrator’.

翻译
这些配置为JPA属性或休眠属性。“ jadira.usertype.javaZone”提供了Java(表示)时区的默认值,从而使您无需在用户类型上将它们指定为参数。“ jadira.usertype.currencyCode”可用于指定在保留不合格货币值时要使用的默认货币代码。“ jadira.usertype.seed”可用于指定要用于生成用于版本控制的时间戳的休眠种子。Jadira提供了两种种子实现方式-DbTimestampSeed从数据库获取值,JvmTimestampSeed使用本地JVM。这些类型可以正确解决分区差异。‘jadira.usertype.autoRegisterUserTypes’ 用于自动注册最常用的类型。这意味着对于任何自动注册的类型,您都不需要提供类型注释。有关支持的类型的完整列表,请查看’AbstractUserTypeHibernateIntegrator’的子类。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值