为了账号安全,请及时绑定邮箱和手机立即绑定

mybatis配置错误

mybatis配置错误

time初夏时光 2017-03-14 14:38:19
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace="/"> <select id="findAllUser2" resultType="hashmap"> SELECT * FROM student </select> <select id="findUserByname" parameterType="String" resultType="hashmap">    SELECT * FROM student where name=#{xxx}    </select> <select id="findUserByUsernameAndNumber" parameterType="domain.User" resultType="domain.User">    SELECT * FROM student where name='${name}' and number='${number}'    </select>     <insert id="insertUserByUsernameAndNumber" parameterType="domain.User">    insert into student(name,number)    value(#{name},'${number}')    </insert>        <update id="updateUserByUsernameAndNumber" parameterType="domain.User">   update student set name='${name}' where number=#{number}     </update>         <delete id="deleteUserByUsernameAndNumber" parameterType="string">     delete from student where  name=#{name}     </delete>            <!-- 子查询 -->>    <select id="findOneDepartment" parameterType="int" resultType="domain.Department">    select * from department    where id=#{id}    </select>    <select id="findAllUserSub" resultMap="findAllUserSub">    select * from student    </select>    <resultMap type="domain.User" id="findAllUserSub">    <id property="name" column="name"/>    <result property="number" column="number"/>    <association column="deptid" property="deptid" javaType="domain.Department" select="findOneDepartment">    </association>    </resultMap>        <!--构造查询   -->    <association column="deptid" property="deptid" javaType="domain.Department">    <constructor>    <arg column="id" javaType="int"/>    <arg column="depname" javaType="String"/>     </constructor>    <id column="id" property="id"></id>    <result column="depname" property="dname"></result>    </association>          <!-- 一对多查询 -->>    <select id="findAllUsercollection" resultMap="resultUsers"> select * from student,department where student.deptid=department.id </select> <resultMap id="resultUsers" type="domain.Department"> <id column="id" property="id"></id> <result column="name" property="name"></result> <collection property="users" column="User.name" javaType="ArrayList" ofType="domain.User"> <result column="username" property="name"></result> <result column="password" property="number"></result> <result column="deptid" property="deptid"></result> </collection> </resultMap> </mapper>
查看完整描述

2 回答

?
霜花似雪

TA贡献36条经验 获得超19个赞

注意resultType,parameterType对应的类型不要写错,其他的错误看不出来,能力有限

查看完整回答
反对 回复 2017-03-14
?
慕粉3233872

TA贡献70条经验 获得超29个赞

把错误信息贴出来

查看完整回答
反对 回复 2017-03-14
  • 2 回答
  • 0 关注
  • 1364 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信