有关Mybatis中的包装器类型的问题

时间:2019-04-19 23:30:17

标签: mysql mybatis

我对Mybatis中的包装器类型有疑问。

我知道Mybatis中的原始类型包装类型都有自己的别名,例如'int'具有别名'_int'和'Integer'具有别名别名“ int”和“ integer”。

如果我不想使用Integer的别名,我曾经使用'java.lang.Integer'来设置'parameterType'。

因此出现了一个问题,如果我只是使用'Integer'(不是Integer的别名)来设置'parameterType',SQL仍然可以正常工作,为什么?

现在'Integer'仍然可以正常工作,为什么mybatis将'int'和'integer'映射为其别名。有什么意义吗?

如果您能告诉我真相,我将非常感谢!!! 想一吨!!!

<select id="getOneArticleById" resultMap="articleWithAutAndCom" parameterType="Integer">
        select * from t_article a,t_user u,t_topic t where a.user_id=u.user_id and a.topic_id=t.topic_id and a.article_id=#{articleId}
</select>

<select id="getOneArticleById" resultMap="articleWithAutAndCom" parameterType="integer">
        select * from t_article a,t_user u,t_topic t where a.user_id=u.user_id and a.topic_id=t.topic_id and a.article_id=#{articleId}
</select>
<select id="getOneArticleById" resultMap="articleWithAutAndCom" parameterType="java.lang.Integer">
        select * from t_article a,t_user u,t_topic t where a.user_id=u.user_id and a.topic_id=t.topic_id and a.article_id=#{articleId}
</select>

<select id="getOneArticleById" resultMap="articleWithAutAndCom" parameterType="int">
        select * from t_article a,t_user u,t_topic t where a.user_id=u.user_id and a.topic_id=t.topic_id and a.article_id=#{articleId}
</select>

0 个答案:

没有答案
相关问题