This content has been marked as final.
Show 4 replies
-
1. Re: Using enums with entity beans
epbernard Sep 21, 2005 5:54 AM (in response to dsouza)you can create an Hibernate UserType and use @Type
-
2. Re: Using enums with entity beans
dsouza Sep 21, 2005 2:57 PM (in response to dsouza)Exactly what I was looking for! Thanks!
However it is the first time I use @Type and I'm having some problems.
As in the docs, I created a UserType class, implemented all methods:public class EnumUserType implements UserType { public Class returnedClass() { return ConditionType.class; } public int[] sqlTypes() { return new int[] { Types.NUMERIC }; } ...
and made the appropriate changes in my entity bean:@Type(type = "mypackage.EnumUserType") @Column(name = "COND_TYPE", nullable = false) public ConditionType getConditionType() { ...
ConditionType is an enum as I described in my previous post.
now I'm getting this when I deploy:org.hibernate.MappingException: Could not determine type for: mypackage.EnumUserType, for columns: [org.hibernate.mapping.Column(COND_TYPE)] at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:266) at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:253) ...
Still can't figure out what I'm doing wrong. Any ideas on what might be causing this? -
3. Re: Using enums with entity beans
dsouza Sep 21, 2005 4:07 PM (in response to dsouza)Never mind that last post... It was a typo in my package's name.
-
4. Re: Using enums with entity beans
onormann Feb 21, 2007 11:40 AM (in response to dsouza)You also can use the @Enumerated - annotation and choose the type ORDINAL or STRING, so you won't get problems with the order of newly added enum-constants.
@Enumerated(EnumType.STRING) @Column(name="CATEGORY", nullable=false) private Category category;