How to register a custom type in Hibernate using org.springframework.orm.hibernate4.LocalSessionFactoryBean

Posted by Luis on Stack Overflow See other posts from Stack Overflow or by Luis
Published on 2012-11-17T11:05:14Z Indexed on 2012/12/17 17:03 UTC
Read the original article Hit count: 405

Filed under:

I'm migrating from hibernate 3 to hibernate 4, In hibernate 3 the way I was registering a custom type was:

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;
}}

I'm now trying to do the same operation but using hibernate 4, my question is how is the best way to do this? since I dont have access do change configuration when using "org.springframework.orm.hibernate4.LocalSessionFactoryBean" instead of "org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean".

Thanks

© Stack Overflow or respective owner

Related posts about spring