Are enums supported by JDBC?

后端 未结 2 528
情歌与酒
情歌与酒 2021-02-11 20:14

I really can\'t find a nice enum JDBC mapping example. Is enum actually supported by JDBC?

I am working with MySQL. I have an enum column, and would like to map to some

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-11 20:53

    Here is some generic solution were are using in converting JDBC values to Java enums.

    param = Enum.valueOf((Class)dbField.getField().getType(), (String) param);
    

    where param is the value of the field in the db , and the dbField is the java.reflect.util.Field , where to put the value to

提交回复
热议问题