今天下午用abator生成ibatis文件后,运行,老是报下面这个异常。按照网上的方法,还是没解决问题。请大侠指点,多谢了!
Exception in thread "main" com.ibatis.sqlmap.client.SqlMapException:
There is no statement named student.selectByPrimaryKey in this SqlMap.
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.getMappedStatement(SqlMapExecutorDelegate.java:231)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:509)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:493)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:106)
at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForObject(SqlMapClientImpl.java:82)
at com.sinojp.dao.StudentDAOImpl.selectByPrimaryKey(StudentDAOImpl.java:66)
at com.sinojp.dao.StudentDAOImpl.main(StudentDAOImpl.java:136)
下面是student_SqlMap.xml配置文件,代码如下:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd" >
<sqlMap
namespace="student" >
<resultMap id="abatorgenerated_StudentResult" class="com.sinojp.domain.Student" >
<result column="id" property="id" jdbcType="INTEGER" />
<result column="name" property="name" jdbcType="VARCHAR" />
</resultMap>
<sql id="Example_Where_Clause" >
<iterate property="oredCriteria" conjunction="or" prepend="where" removeFirstPrepend="iterate" >
<isEqual property="oredCriteria[].valid" compareValue="true" >
(
<iterate prepend="and" property="oredCriteria[].criteriaWithoutValue" conjunction="and" >
$oredCriteria[].criteriaWithoutValue[]$
</iterate>
<iterate prepend="and" property="oredCriteria[].criteriaWithSingleValue" conjunction="and" >
$oredCriteria[].criteriaWithSingleValue[].condition$
#oredCriteria[].criteriaWithSingleValue[].value#
</iterate>
<iterate prepend="and" property="oredCriteria[].criteriaWithListValue" conjunction="and" >
$oredCriteria[].criteriaWithListValue[].condition$
<iterate property="oredCriteria[].criteriaWithListValue[].values" open="(" close=")" conjunction="," >
#oredCriteria[].criteriaWithListValue[].values[]#
</iterate>
</iterate>
<iterate prepend="and" property="oredCriteria[].criteriaWithBetweenValue" conjunction="and" >
$oredCriteria[].criteriaWithBetweenValue[].condition$
#oredCriteria[].criteriaWithBetweenValue[].values[0]# and
#oredCriteria[].criteriaWithBetweenValue[].values[1]#
</iterate>
)
</isEqual>
</iterate>
</sql>
<select id="selectByPrimaryKey" resultMap="StudentResult" parameterClass="com.sinojp.domain.Student" >
select id, name
from student
where id = #id:INTEGER#
</select> <select id="selectByExample" resultMap="StudentResult" parameterClass="com.sinojp.domain.StudentExample" >
select id, name
from student
<isParameterPresent >
<include refid="student.Example_Where_Clause" />
<isNotNull property="orderByClause" >
order by $orderByClause$
</isNotNull>
</isParameterPresent>
</select>
<delete id="deleteByPrimaryKey" parameterClass="com.sinojp.domain.Student" >
delete from student
where id = #id:INTEGER#
</delete>
<delete id="deleteByExample" parameterClass="com.sinojp.domain.StudentExample" >
delete from student
<include refid="student.Example_Where_Clause" />
</delete>
<insert id="insert" parameterClass="com.sinojp.domain.Student" >
insert into student (name)
values (#name:VARCHAR#)
<selectKey resultClass="java.lang.Integer" keyProperty="id" >
SELECT LAST_INSERT_ID()
</selectKey>
</insert>
<update id="updateByPrimaryKey" parameterClass="com.sinojp.domain.Student" >
update student
set name = #name:VARCHAR#
where id = #id:INTEGER#
</update>
<update id="updateByPrimaryKeySelective" parameterClass="com.sinojp.domain.Student" >
update student
<dynamic prepend="set" >
<isNotNull prepend="," property="name" >
name = #name:VARCHAR#
</isNotNull>
</dynamic>
where id = #id:INTEGER#
</update>
<select id="countByExample" parameterClass="com.sinojp.domain.StudentExample" resultClass="java.lang.Integer" >
select count(*) from student
<include refid="student.Example_Where_Clause" />
</select>
<update id="updateByExampleSelective" >
update student
<dynamic prepend="set" >
<isNotNull prepend="," property="record.id" >
id = #record.id:INTEGER#
</isNotNull>
<isNotNull prepend="," property="record.name" >
name = #record.name:VARCHAR#
</isNotNull>
</dynamic>
<isParameterPresent >
<include refid="student.Example_Where_Clause" />
</isParameterPresent>
</update>
<update id="updateByExample" >
update student
set id = #record.id:INTEGER#,
name = #record.name:VARCHAR#
<isParameterPresent >
<include refid="student.Example_Where_Clause" />
</isParameterPresent>
</update>
</sqlMap>
SqlMapConfig.xml配置文件,代码如下:
<?xml version ="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMapConfig PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
<sqlMapConfig >
<properties resource="com/sinojp/configuration/SqlMap.properties"/>
<transactionManager type="JDBC">
<dataSource type="SIMPLE">
<property value="${driver}" name="JDBC.Driver"/>
<property value="${url}" name="JDBC.ConnectionURL"/>
<property value="${username}" name="JDBC.Username"/>
<property value="${password}" name="JDBC.Password"/>
</dataSource>
</transactionManager>
<settings useStatementNamespaces="true" /> <sqlMap resource="com/sinojp/configuration/student_SqlMap.xml" />
</sqlMapConfig>