MyBatisの解決データベースフィールドの名前属性の矛盾とPOJO

データベースフィールド:

 Javaクラス:

Mapper.xmlファイルに次の設定を追加します。

栗のために

<!--结果集映射-->
    <resultMap id="userResultMap" type="com.qian.pojo.User">
        <!--主键-->
        <id property="userId" column="user_id"/>
        <result property="userName" column="user_name"/>
        <result property="userPassword" column="user_password"/>
        <result property="userGender" column="user_gender"/>
    </resultMap>


    <select id="getUserByNameAndPassword" resultMap="userResultMap">
        SELECT *
        FROM test.tb_userinfo
        WHERE user_name = #{userName} and user_password=#{userPassword};
    </select>

 

公開された73元の記事 ウォン称賛88 ビュー10000 +

おすすめ

転載: blog.csdn.net/qq_42013035/article/details/104222406