Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Hibernate:在项目范围内定义类型映射_Java_Hibernate - Fatal编程技术网

Java Hibernate:在项目范围内定义类型映射

Java Hibernate:在项目范围内定义类型映射,java,hibernate,Java,Hibernate,我正在使用Hibernate和Joda Time,并得到了UserType库的支持 我可以使用以下方法持续约会: @Type(type="org.jadira.usertype.dateandtime.joda.PersistentDateTime") @Column private DateTime startDate; 然而,我想知道是否有可能在某个地方定义一次映射,而不是在DateTime类型的每个实例上 在从Hibernate 3.4->4.0迁移时,不得不从JodaTime Hibe

我正在使用Hibernate和Joda Time,并得到了UserType库的支持

我可以使用以下方法持续约会:

@Type(type="org.jadira.usertype.dateandtime.joda.PersistentDateTime")
@Column
private DateTime startDate;
然而,我想知道是否有可能在某个地方定义一次映射,而不是在
DateTime
类型的每个实例上


在从Hibernate 3.4->4.0迁移时,不得不从JodaTime Hibernate切换到UserType,我不愿意在整个域模型中乱丢类型声明。

您可以实现一个
基本类型
,并在构建
会话工厂时注册它。hibernate参考手册在中对此进行了解释

在Usertype的3.0.0.CR1版本中,您可以利用以下类型的自动注册:

PersistentBigMoneyAmount
PersistentMoneyAmount
PersistentCurrency
PersistentCurrencyUnit
PersistentDateTime
PersistentDurationAsString
PersistentInstantAsTimestamp
PersistentLocalDate
PersistentLocalTime
PersistentMonthDayAsString
PersistentPeriodAsString
PersistentTimeOfDay
PersistentYearMonthDay
PersistentYears
要启用此功能,需要将JPA或Hibernate属性“jadira.usertype.autoRegisterUserTypes”设置为“true”

升级usertype.joda Maven工件时,现在称为“usertype.core”

更多信息在这里