Announcement Announcement Module
No announcement yet.
How to register a custom type in Hibernate 4 using LocalSessionFactoryBean Page Title Module
Move Remove Collapse
Conversation Detail Module
  • 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:

    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;
    protected Configuration newConfiguration() throws HibernateException {
        Configuration configuration = super.newConfiguration();
        if (CollectionUtils.hasEntries(customTypes)) {
            for (BasicType customType:customTypes) {
        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".


  • #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:

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

    Hope I did help you.

    Luis Costa.