Announcement Announcement Module
Collapse
No announcement yet.
How to register a custom type in Hibernate 4 using LocalSessionFactoryBean Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to register a custom type in Hibernate 4 using LocalSessionFactoryBean

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

    Code:
    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.LocalSessionFa ctoryBean" instead of "org.springframework.orm.hibernate3.annotation.Ann otationSessionFactoryBean".

    Thanks

  • #2
    Hi, actually I did solve the problem, for that I didn’t use spring but I followed has described in hibernate documentation you can find it here: http://docs.jboss.org/hibernate/anno...ml/entity.html

    Package level annotations are placed in a file named package-info.java in the appropriate package. Place your annotations before the package declaration.

    Hope I did help you.

    Luis Costa.

    Comment

    Working...
    X