Mybatis resultmap enum

2020-02-20 15:43

Register custom Enum TypeHandler using @Result annotation. Hi, I have a custom TypeHandler: public class PerfilTypeHandler extends BaseTypeHandler. (Perfil is a Enum class. ) I wantMyBatis handles enum out of the box. What you need to do is select the right type handler for your enums. By default, MyBatis converts enums using enum. name() so it works if the database column is a char, varchar or enum. If you go with ordinals, you can replace de default type handler using: mybatis resultmap enum

public static ResultSetType valueOf (String name) public static final ResultSetType[ values () Generated by Doclava.

May 02, 2017 Indeed, database value GROUP belongs to secong enum instead of I start debugging and found what instantiated once. And placed into registry by handler ignore handled target class. You wont even have to mention your typeHandler in your resultMap, mybatis will take care of it whenever it comes across a SpeedStatus Enum in your Pojo.mybatis resultmap enum DAYTYPE in your case contains a member id. Now if you store your ENUM as id in the database you can always use a which can handle the DAYTYPE for you even if you don't have your Enum synced with your database.

Rating: 4.30 / Views: 585

Mybatis resultmap enum free

typeHandlers. Whenever MyBatis sets a parameter on a PreparedStatement or retrieves a value from a ResultSet, a TypeHandler is used to retrieve the value in a means appropriate to the Java type. The following table describes the default TypeHandlers. NOTE mybatis resultmap enum