Let's say we have an enum with custom values, used as a persistent field in an 
entity:

public enum Sex {
  | 
  |     MALE(77),
  |     FEMALE(99);
  | 
  |     public int getValue() {
  |             return value;
  |     }
  | 
  |     int value;
  | 
  |     Sex(int v) {
  |             value = v;
  |     }
  | }

The spec defines two ways to map the enum property with the DB field:

        Sex.MALE <=> 0
  |     Sex.FEMALE <=> 1
  |          // the default one, i.e. the var.ordinal() value
  | 
or

        Sex.MALE <=> "MALE"
  |     Sex.FEMALE <=> "FEMALE"
  |         // using @Enumerated(STRING)
  | 
  | 
That's ok, but is there an easy way to use some kind of custom mapping? 

In this case:

        Sex.MALE <=> 77
  |     Sex.FEMALE <=> 99
  |          // i.e. the user-defined var.getValue() result
  | 


View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3929351#3929351

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3929351


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to