This should point you in the right direction. http://opensource.atlassian.com/confluence/oss/display/IBATIS/How+do+I+u se+a+Custom+Type+Handler+with+complex+property+or+Type+Safe+Enumeration
However if you are going to be using multiple Enums I really like the Using Enums with annotations example. http://opensource.atlassian.com/confluence/oss/display/IBATIS/How+do+I+u se+Enums+with+annotations With it in place adding a new Enum becomes as simple as creating an extension of EnumTypeHandler @EnumTypeHandler(enumClass = YourEnumType.class, jdbcType = Types.VARCHAR) public class YourEnumTypeHandler extends EnumTypeHandlerImpl { // Configured Via EnumTypeHandlerImpl } And then adding a typeHandler to your sqlMapConfig <typeHandler javaType="com.blah.domain.YourEnumType " callback="com.blah.handler.YourEnumTypeHandlerHandler"/> Hope this helps, - Doug -----Original Message----- From: MrNobody [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 05, 2007 8:15 AM To: [email protected] Subject: How do you suggest working with enums? If I have an enum to represent a lookup table, like: public enum Color { RED (1, "Red"), GREEN (2, "Green"), BLUE (3, "Blue"); } What is the best practice for both writing this enums into the database and instantiating enums for the values read from the databse, using iBATIS ? Somewhere, something would have to convert that Color to it's ID (like 3 for Blue) when writing to the DB, and someone else will have to create a enum base don the ID read (3 to Color.BLUE) Any suggestions? -- View this message in context: http://www.nabble.com/How-do-you-suggest-working-with-enums--tf4950616.h tml#a14174681 Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
