问题描述
<sqlMap> <typeAlias alias="emp" type="com.resunly.ibatis.Emp"/> <resultMap id="empMAPResult" class="emp"> <result property="id" column="id" /> <result property="empName" column="empname"/> <result property="empAddr" column="empaddr"/> <result property="empSex" column="empsex"/> <result property="departName" column="depart.depname"/> <result property="des" column="depart.des"/> </resultMap> <select id="getEmp" parameterClass="java.lang.String" resultMap="empMAPResult" > <![CDATA[ select a.empName as empName, a.empAddr as empAddr, a.empSex as empSex, b.depName as departName, b.des as des from emp a, depart as b where a.departNo=b.depNo ]]> </select></sqlMap> 老被提示ORA-00933: SQL command not properly ended 不真的是哪裡的錯誤,幫忙看下 问题补充:<div class="quote_title">yanq12 写道</div><div class="quote_div"><div class="quote_title">引用</div><div class="quote_div">select a.empName as empName, <br /> a.empAddr as empAddr, <br /> a.empSex as empSex, <br /> b.depName as departName, <br /> b.des as des <br /> from emp a, depart as b where a.departNo=b.depNo </div><br /><br />depart as b 错在这里, oracle表的表名不让用as 这边把as去掉就行了<br /></div><br />但是 以去掉 表明後面的AS <select id="getEmp" parameterClass="java.lang.String" resultMap="empMAPResult" > <br /> <![CDATA[ <br /> select a.empName as empName, <br /> a.empAddr as empAddr, <br /> a.empSex as empSex, <br /> b.depName as departName, <br /> b.des as des <br /> from emp a, depart as b where a.departNo=b.depNo <br /> ]]> <br /> </select> <br /> 這一部份會再xml文件里報紅色錯誤,不真的爲什麽 。。。
解决方案
引用resultMap 里是6个字段, select 里是 5个字段我自己模拟试了下,不会报错啊
解决方案二:
引用<resultMap id="empMAPResult" class="emp"> <result property="id" column="id" /> <result property="empName" column="empname"/> <result property="empAddr" column="empaddr"/> <result property="empSex" column="empsex"/> <result property="departName" column="depart.depname"/> <result property="des" column="depart.des"/> </resultMap> 引用select a.empName as empName, a.empAddr as empAddr, a.empSex as empSex, b.depName as departName, b.des as des from emp a, depart b where a.departNo=b.depNo resultMap 里是6个字段, select 里是 5个字段
解决方案三:
select a.id as id, a.empName as empName, a.empAddr as empAddr, a.empSex as empSex, b.depName as departName, b.des as des from emp a, depart b where a.departNo=b.depNo
解决方案四:
引用Make sure that all result coumns in a resultMap are in the field list of select statementselect里少了select id
解决方案五:
引用 這一部份會再xml文件里報紅色錯誤,不真的爲什麽 。。。 报什么错呢?select a.empName as empName, a.empAddr as empAddr, a.empSex as empSex, b.depName as departName, b.des as des from emp a, depart b where a.departNo=b.depNo 这是个正常的SQL语句
解决方案六:
<![CDATA[ select password from user where username = #username#]]> 这种带参数的语句才需要parameterClass吧
解决方案七:
引用<select id="getEmp" parameterClass="java.lang.String" 你sql语句里的parameter呢?
解决方案八:
引用select a.empName as empName, a.empAddr as empAddr, a.empSex as empSex, b.depName as departName, b.des as des from emp a, depart as b where a.departNo=b.depNo depart as b 错在这里, oracle表的表名不让用as 这边把as去掉就行了