数据库字段与实体类字段不一致,导致功能正常,但是就是查不出数据
1.使用resultMap 在xml中定义resultMap标签
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 <resultMap type ="com.entity.BdipChatPoint" id ="pointMap" > <id column ="id_" property ="id" /> <result column ="json" property ="json" /> <result column ="picture" property ="picture" /> <result column ="model_url" property ="modelUrl" /> <result column ="db_id" property ="dbId" /> <result column ="frag_id" property ="fragId" /> <result column ="view_point_num" property ="viewPointNum" /> <result column ="user_name" property ="userName" /> <result column ="head_image" property ="headImage" /> <result column ="tree_id" property ="treeId" /> <result column ="enable_" property ="enable" /> <result column ="remark_" property ="remark" /> <result column ="create_by" property ="createBy" /> <result column ="create_time" property ="createTime" /> <result column ="update_time" property ="updateTime" /> <result column ="update_by" property ="updateBy" /> </resultMap >
column 填写数据库字段 property 填写实体类字段
在使用标签的时候用resultMap=”pointMap”替换resultType=”com.entity.BdipChatPoint”
2.在写sql是使用as 1 2 3 4 <select id ="selectBimChatPoint" parameterType ="com.entity.BdipChatPoint" resultType ="com.entity.BdipChatPoint" > select id_ as id,json,picture,model_url as modelUrl from bdip_chat_point where db_id = #{dbId} and model_url = #{modelUrl} and create_by = #{createBy}</select >
注意id_ as id和model_url as modelUrl
依旧使用resultType来接收