Total Pageviews

Tuesday, June 13, 2006

Updating to Hibernate Core 3.2.0.cr2

After updating from Hibernate Core 3.1.2 and Hibernate Annotation 3.1beta8 to Hibernate Core 3.2.0.cr2 and Hibernate Annotations 3.2.0.cr1 I was facing two problems:
  1. Caused by: javax.persistence.PersistenceException:
    org.hibernate.cache.CacheException:
    Attempt to restart an already started EhCacheProvider.
    Use sessionFactory.close() between repeated calls to
    buildSessionFactory.
    Consider using net.sf.ehcache.hibernate.SingletonEhCacheProvider.
    Error from ehcache was: Cannot parseConfiguration
    CacheManager. Attempt to create a new instance of
    CacheManager using the diskStorePath "/tmp" which
    is already used by an existing CacheManager.

    Solution:

    Setting the hibernate property:

    hibernate.cache.provider_class=org.hibernate.cache.HashtableCacheProvider


    Setting the property to net.sf.ehcache.hibernate.SingletonEhCacheProvider may work as well,
    but I haven't test yet.
  2. org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class:...

    I had a property annotated with @OneToMany targeting an @Embedabble @MappedSuperclass.

    I found the solution in the Hibernate Forum:

    http://forum.hibernate.org/viewtopic.php?t=959542&highlight=onetomany+
    manytomany+targeting+unmapped+class

    To summarize:

    You should use @CollectionOfElements instead of @*ToMany, if your association is not pointing to an entity.