Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.1.3
Mapping documents:
Code:
<typedef name="Status" class="com.foo.dao.GenericEnumUserType">
<param name="enumClass">com.foo.model.Response$Status</param>
<param name="identifierMethod">toInt</param>
<param name="valueOfMethod">fromInt</param>
</typedef>
<class name="com.foo.model.Response" table="response">
.
.
.
<property name="status" type="Status" column="response_status" />
Full stack trace of any exception that occurs:Code:
org.hibernate.MappingException: Could not determine type for: com.foo.dao.GenericEnumUserType, for columns: [org.hibernate.mapping.Column(response_status)]
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:395)
at org.hibernate.mapping.RootClass.validate(RootClass.java:192)
at org.hibernate.cfg.Configuration.validate(Configuration.java:984)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1169)
I'm implementing the "flexible" enumeration user type as described in
http://hibernate.org/272.html. As far as I can tell I've followed the instructions to the letter and yet I can't get it working. My class looks like this:
Code:
public class Response implements Serializable {
public enum Status implements Serializable {
New(0), Read(1), Unknown(-1);
int value;
private Status(int value) {
this.value = value;
}
public Status valueOf(int value) {
switch (value) {
case 0 : return New;
case 1 : return Read;
default: return Unknown;
}
}
public int toInt() {
return value;
}
}
.
.
.
}
Any thoughts?