Spring boot 寄存器DynamicParameterizedType全局
如何在hibernate中注册全局可用的Spring boot 寄存器DynamicParameterizedType全局,spring-boot,hibernate,jpa,Spring Boot,Hibernate,Jpa,如何在hibernate中注册全局可用的DynamicParameterizedType 我写了以下类型: 公共类QuantityType扩展AbstractSingleColumnStandardBasicType resolvedUnit=resolveUnit(读卡器); setJavaTypeDescriptor(新的QuantityJavaDescriptor(resolvedUnit)); } 私有单元解析单元(参数类型读取器){…} } 并在hibernate中向服务注册中心注册
DynamicParameterizedType
我写了以下类型:
公共类QuantityType扩展AbstractSingleColumnStandardBasicType resolvedUnit=resolveUnit(读卡器);
setJavaTypeDescriptor(新的QuantityJavaDescriptor(resolvedUnit));
}
私有单元解析单元(参数类型读取器){…}
}
并在hibernate中向服务注册中心注册:
公共类QuantityTypeRegistration实现TypeContributor{
@凌驾
公共无效贡献(类型贡献类型贡献,ServiceRegistry ServiceRegistry){
typeContributions.ContributyType(QuantityType.INSTANCE);
}
}
如果在实体中使用该类型,则会调用JavaTypeDescriptor的wrap/unwrap方法,
但是调用的不是参数化的JavaTypeDescriptor,而是默认的JavaTypeDescriptor。由于某些原因,未调用setParameterValues
方法
代码:也许答案会有用。我想您根本不应该通过
TypeContributor
使用注册。这将需要对每次使用进行@Type注释,我希望将该类型作为现成的功能。最好的情况是将代码作为依赖项包含,使用类型,它就可以工作了。似乎这样不行: