mybatis parameterType

怼烎@ 2023-01-06 05:29 219阅读 0赞

parameterType可以是基本类型,引用类型(例如:String 类型),还可以是实体类类型(POJO 类)同时也可以使用实体类的包装类

基本类型和String我们可以直接写类型名称,也可以使用包名.类名的方式,例如:java.lang.String
实体类类型,目前我们只能使用全限定类名。

原因,是 mybaits 在加载时已经把常用的数据类型注册了别名,从而我们在使用时可以不写包名,而我们的是实体类并没有注册别名,所以必须写全限定类名。
TypeAliasRegistery.class中定义:

  1. this.registerAlias("string", String.class);
  2. this.registerAlias("byte", Byte.class);
  3. this.registerAlias("long", Long.class);
  4. this.registerAlias("short", Short.class);
  5. this.registerAlias("int", Integer.class);
  6. this.registerAlias("integer", Integer.class);
  7. this.registerAlias("double", Double.class);
  8. this.registerAlias("float", Float.class);
  9. this.registerAlias("boolean", Boolean.class);
  10. this.registerAlias("byte[]", Byte[].class);
  11. this.registerAlias("long[]", Long[].class);
  12. this.registerAlias("short[]", Short[].class);
  13. this.registerAlias("int[]", Integer[].class);
  14. this.registerAlias("integer[]", Integer[].class);
  15. this.registerAlias("double[]", Double[].class);
  16. this.registerAlias("float[]", Float[].class);
  17. this.registerAlias("boolean[]", Boolean[].class);
  18. this.registerAlias("_byte", Byte.TYPE);
  19. this.registerAlias("_long", Long.TYPE);
  20. this.registerAlias("_short", Short.TYPE);
  21. this.registerAlias("_int", Integer.TYPE);
  22. this.registerAlias("_integer", Integer.TYPE);
  23. this.registerAlias("_double", Double.TYPE);
  24. this.registerAlias("_float", Float.TYPE);
  25. this.registerAlias("_boolean", Boolean.TYPE);
  26. this.registerAlias("_byte[]", byte[].class);
  27. this.registerAlias("_long[]", long[].class);
  28. this.registerAlias("_short[]", short[].class);
  29. this.registerAlias("_int[]", int[].class);
  30. this.registerAlias("_integer[]", int[].class);
  31. this.registerAlias("_double[]", double[].class);
  32. this.registerAlias("_float[]", float[].class);
  33. this.registerAlias("_boolean[]", boolean[].class);
  34. this.registerAlias("date", Date.class);
  35. this.registerAlias("decimal", BigDecimal.class);
  36. this.registerAlias("bigdecimal", BigDecimal.class);
  37. this.registerAlias("biginteger", BigInteger.class);
  38. this.registerAlias("object", Object.class);
  39. this.registerAlias("date[]", Date[].class);
  40. this.registerAlias("decimal[]", BigDecimal[].class);
  41. this.registerAlias("bigdecimal[]", BigDecimal[].class);
  42. this.registerAlias("biginteger[]", BigInteger[].class);
  43. this.registerAlias("object[]", Object[].class);
  44. this.registerAlias("map", Map.class);
  45. this.registerAlias("hashmap", HashMap.class);
  46. this.registerAlias("list", List.class);
  47. this.registerAlias("arraylist", ArrayList.class);
  48. this.registerAlias("collection", Collection.class);
  49. this.registerAlias("iterator", Iterator.class);
  50. this.registerAlias("ResultSet", ResultSet.class);

发表评论

表情:
评论列表 (有 0 条评论,219人围观)

还没有评论,来说两句吧...

相关阅读

    相关 mybatis parameterType

    parameterType可以是基本类型,引用类型(例如:String 类型),还可以是实体类类型(POJO 类)同时也可以使用实体类的包装类 基本类型和String我们可以