ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "levan Dvalishvili" <ad...@amostudio.com>
Subject Enum Type
Date Mon, 29 May 2006 17:20:53 GMT
Hi All! 
I am need to this mailing ,a s a fact this is my first question here .. 

I am working on a project and would like to use ENUM as an attribute on my
bean  like this :

------------------ SAMPLE CODE ------------------------
public class Shipment  implements  Serializable{
enum ShipmentStatus{notShipped("Not Shiped"),
			  onTheWay("on the way"),
			  arrived("Arrived");

      private String value; 
       
      ShipmentStatus(String newValue) {
          value = newValue; 
      } 
      
      
      ShipmentStatus() {
          value="NOT SPECIFIED";
      } 
      String getShipmentStatus() { return value; } 
   }
    
    private ShipmentStatus Status;
    private Date departureDate;
    private ShipmentStatus Status;
    private Date ArivalDate;
 etc .....
}
---------------------- END OF SAMPLE CODE --------------------------------

I am working into IBATIS as I go ..., and would like to ask if this way will
work with the mapping? Do I have to write a custom type handler? 
I also have ac corresponding enum on database side (DB is mySQL) Has
anything like that been done yet? Is this a right way of doing it or should
I just forget about ENUM  and just use string?
Best regards
And thanks for creating such a great product 
Levan.




Mime
View raw message