我正在从休眠 3 迁移到休眠 4,在休眠 3 中,我注册自定义类型的方式是:
public class AnnotationSessionFactoryBean extends org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean {
private Collection<? extends BasicType> customTypes;
public Collection<? extends BasicType> getCustomTypes() {
return customTypes;
}
public void setCustomTypes(Collection<? extends BasicType> customTypes) {
this.customTypes = customTypes;
}
@Override
protected Configuration newConfiguration() throws HibernateException {
Configuration configuration = super.newConfiguration();
if (CollectionUtils.hasEntries(customTypes)) {
for (BasicType customType:customTypes) {
configuration.registerTypeOverride(customType);
}
}
return configuration;
}}
我现在正在尝试执行相同的操作,但使用休眠 4,我的问题是最好的方法是如何做到这一点?因为我无权使用“org.springframework.orm.hibernate4.LocalSessionFactoryBean”而不是“org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean”时更改配置。
谢谢