[英]Hibernate: Trouble using sessionFactory.getTypeHelper().custom(userType)
Hibernate.custom(userType)在Hibernate 5.2.10.Final中消失了,所以我必须使用sessionFactory.getTypeHelper()。custom(userType)。 没有SessionFactory,有没有办法获取TypeHelper? 以前我使用的是休眠3.6.10.Final。 我宁愿不使用sessionFactory,但我真的找不到解决它的方法。
主要目标是采用org.hibernate.usertype.UserType并返回org.hibernate.type.Type。
我在3.6.10.Final中具有此功能
public Type getHibernateType() {
// Type is class that implements hibernates UserType
return Hibernate.custom(UserType)
}
在5.2.10.Final中,我不得不将其更改为类似
public Type getHibernateType() {
return sessionFactory.getTypeHelper().custom(UserType);
}
如果可以帮助的话,我真的不想使用sessionFactory。 所以我想知道是否还有另一种获取Type的方法。
好吧,从技术上讲,5.2仍然通过TypeFactory
以静态方法公开了该功能。
Type type = TypeFactory.custom( UserType.class, null, null );
但是,请注意,此方法已标记为@Deprecated
,实际上,作为Hibernate 6.0的类型系统检修的一部分,已删除了整个类。
我会习惯使用SessionFactory
访问此信息的概念,因为这正是我们目前设计6.0的方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.