SoFunction
Updated on 2025-03-03

mybatis resultType's own data type alias interpretation

mybatis resultType comes with data type alias

To simplify development, mybatis defaults to us in

Define some common classes aliases

public TypeAliasRegistry() {
    registerAlias("string", );

    registerAlias("byte", );
    registerAlias("long", );
    registerAlias("short", );
    registerAlias("int", );
    registerAlias("integer", );
    registerAlias("double", );
    registerAlias("float", );
    registerAlias("boolean", );

    registerAlias("byte[]", Byte[].class);
    registerAlias("long[]", Long[].class);
    registerAlias("short[]", Short[].class);
    registerAlias("int[]", Integer[].class);
    registerAlias("integer[]", Integer[].class);
    registerAlias("double[]", Double[].class);
    registerAlias("float[]", Float[].class);
    registerAlias("boolean[]", Boolean[].class);

    registerAlias("_byte", );
    registerAlias("_long", );
    registerAlias("_short", );
    registerAlias("_int", );
    registerAlias("_integer", );
    registerAlias("_double", );
    registerAlias("_float", );
    registerAlias("_boolean", );

    registerAlias("_byte[]", byte[].class);
    registerAlias("_long[]", long[].class);
    registerAlias("_short[]", short[].class);
    registerAlias("_int[]", int[].class);
    registerAlias("_integer[]", int[].class);
    registerAlias("_double[]", double[].class);
    registerAlias("_float[]", float[].class);
    registerAlias("_boolean[]", boolean[].class);

    registerAlias("date", );
    registerAlias("decimal", );
    registerAlias("bigdecimal", );
    registerAlias("biginteger", );
    registerAlias("object", );

    registerAlias("date[]", Date[].class);
    registerAlias("decimal[]", BigDecimal[].class);
    registerAlias("bigdecimal[]", BigDecimal[].class);
    registerAlias("biginteger[]", BigInteger[].class);
    registerAlias("object[]", Object[].class);

    registerAlias("map", );
    registerAlias("hashmap", );
    registerAlias("list", );
    registerAlias("arraylist", );
    registerAlias("collection", );
    registerAlias("iterator", );

    registerAlias("ResultSet", );
  }

Organize into a table

Alias Mapping type
string
byte
long
short
int
integer
double
float
boolean
byte[] []
long[] []
short[] []
int[] []
integer[] []
double[] []
float[] []
boolean[] []
_byte byte
_long long
_short short
_int int
_integer int
_double double
_float float
_boolean boolean
_byte[] byte[]
_long[] long[]
_short[] short[]
_int[] int[]
_integer[] int[]
_double[] double[]
_float[] float[]
_boolean[] boolean[]
date
decimal
bigdecimal
biginteger
object
date[] []
decimal[] []
bigdecimal[] []
biginteger[] []
object[] []
map
hashmap
list
arraylist
collection
iterator
ResultSet

Summarize

The above is personal experience. I hope you can give you a reference and I hope you can support me more.