Workaround for Issue with @Any Mapping in Hibernate Tools Plugin

Posted On // Leave a Comment
There is a slight problem with 3.2.3.GA release of Hibernate Tools when specifically dealing with the @Any (or the <any> element if you are using xml to configure hibernate) type of relationship. The problem manifests itself with an exception that contains the message "org.hibernate.MappingException: property mapping has wrong number of columns" when you try to open the session factory in Eclipse.

I've found a work-around to this problem by updating some of the hibernate jars in the base plugin for Hibernate tools in eclipse.

(In the instructions below, replace <eclipse-home> with the location that you've installed Eclipse. Also, the direction of the slashes may be different for you depending on what platform you are on.)

  1. First, stop Eclipse.

  2. Next grab the and put it at <eclipse-home>\plugins\org.hibernate.eclipse_3.2.3.GA\lib\hibernate\hibernate3.jar

  3. Grab hibernate-annotations-3.3.1.GA.jar and put at <eclipse-home>\plugins\org.hibernate.eclipse_3.2.3.GA\lib\annotations\hibernate-annotations.jar

  4. Grab and put at <eclipse-home>\plugins\org.hibernate.eclipse_3.2.3.GA\lib\annotations\hibernate-commons-annotations.jar

  5. Restart eclipse and try to use your project with the @Any mapping again.