MyBatis中 ofType和javaType区别

转自:https://blog.csdn.net/u013216156/article/details/78642920/

JavaType和ofType都是用来指定对象类型的,但是JavaType是用来指定pojo中属性的类型,而ofType指定的是映射到list集合属性中pojo的类型

pojo类:

publicclass User {

    privateint id;

    privateString username;

    privateString mobile;

    privateListposts;

}

 

user.xml:

"User" id="resultUserMap">

         "id" javaType="int" column="user_id" />

         "username" javaType="string" column="username" />

         "mobile"  column="mobile" />

                       

         "posts"  ofType="com.spenglu.Post"  javaType="java.util.ArrayList" column="userid">

             "id" column="post_id" javaType="int" jdbcType="INTEGER"/>   

            "title" column="title" javaType="string" jdbcType="VARCHAR"/>

            "content" column="content" javaType="string" jdbcType="VARCHAR"/>

         

    

你可能感兴趣的:(数据库,java,mybatis,sql)