search

Home  >  Q&A  >  body text

java - Spring boot mybatis custom converter problem

When spring boot is integrated with mybatis, the custom typehandler (converter) is not called
First, the table structure

Entity

Enumeration type

Custom handler

mybatis.type-handlers-package has been configured

Here comes a great assist

ringa_leeringa_lee2789 days ago1339

reply all(1)I'll reply

  • PHP中文网

    PHP中文网2017-06-14 10:56:51

    Mybatis will use EnumTypeHandler to handle Enum type by default, see the following code:

    if (handler == null && type != null && type instanceof Class &&         
           Enum.class.isAssignableFrom((Class<?>) type)) {
        handler = new EnumTypeHandler((Class<?>) type);
    }

    If you want to use your own typeHandler, you need to register your own typeHandler first, and then set the typeHandler when setting parameters and getting results.

    reply
    0
  • Cancelreply