I am trying to map a Java 5 enum to an int column in the database.
I'm using
Code:
<property name="kind" type="com.mycompany.FooBar.KindUserType">
<meta attribute="property-type">com.mycompany.FooBar.Kind</meta>
</property>
Code:
public class FooBar {
...
public static enum Kind { ... }
public static class KindUserType implements EnhancedUserType { ... }
}
and I get this error:
Code:
org.hibernate.MappingException: Could not determine type for: com.mycompany.FooBar.KindUserType, for columns: [org.hibernate.mapping.Column(kind)]
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:266)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:253)
at org.hibernate.mapping.Property.isValid(Property.java:185)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:440)
at org.hibernate.mapping.RootClass.validate(RootClass.java:192)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1102)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1287)
...
However, if I move KindUserType so that it is a stand alone class (not
an inner class) it works fine. It works fine with the enum as an
inner class, so it doesn't seem like it could be a classpath problem.
So is this just a hibernate bug or is there something I am missing?
hibernate-3.2.6.ga, jboss-4.2.3.GA, jdk1.5.0_15_64bit