首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2ME开发 >

spring+ibatis下出错:There is no statement named selectSQL in this SqlMap

2014-03-13 
spring+ibatis下报错:There is no statement named selectSQL in this SqlMapThere is no statement named

spring+ibatis下报错:There is no statement named selectSQL in this SqlMap
There is no statement named selectSQL in this SqlMap
代码如下:

beans-ibatis.xml:
<bean id="meatOutInfoBaseDao" class="com.sunraw.kunming.dao.impl.MeatOutInfoBaseDaoImpl">
<property name="sqlMapClient">
<ref local="client" />
</property>
</bean>

<bean name="meatOutInfoBaseService"
class="com.sunraw.kunming.service.impl.MeatOutInfoBaseServiceImpl">
<property name="meatOutInfoBaseDao">
<ref bean="meatOutInfoBaseDao" />
</property>
</bean>

SqlMapConfig.xml:
<sqlMapConfig>
<!--定义iBATIS自身应用信息-->
<settings cacheModelsEnabled="true" enhancementEnabled="true"
lazyLoadingEnabled="true" maxRequests="200" maxSessions="100"
maxTransactions="20" useStatementNamespaces="true" />


<sqlMap resource="User.xml" />
<sqlMap resource="MeatOutInfoBase.xml" />
<sqlMap resource="MeatOutInfoDetail.xml" />
<sqlMap resource="MeatOutInfoSendFail.xml" />
</sqlMapConfig>

MeatOutInfoBase.xml:
<sqlMap namespace="MeatOutInfoBase">

<typeAlias alias="MeatOutInfoBase" type="com.sunraw.kunming.model.MeatOutInfoBase" />

<resultMap id="SelectResult" class="MeatOutInfoBase">
<result property="tranId" column="TRAN_ID" />
<result property="butcherFacId" column="BUTCHER_FAC_ID" />
<result property="butcherFacName" column="BUTCHER_FAC_NAME" />
<result property="transantionDate" column="TRANSANTION_DATE" />
<result property="sellerId" column="SELLER_ID" />
<result property="sellerName" column="SELLER_NAME" />
<result property="buyerId" column="BUYER_ID" />
<result property="buyerName" column="BUYER_NAME" />
<result property="dest" column="DEST" />
<result property="sendState" column="SEND_STATE" />
<result property="sendFailReson" column="SEND_FAIL_RESON" />
</resultMap>

<select id="selectSQL" resultMap="SelectResult">
<![CDATA[
select
TRAN_ID,
BUTCHER_FAC_ID,
BUTCHER_FAC_NAME,
TRANSANTION_DATE,
SELLER_ID,
SELLER_NAME,
BUYER_ID,
BUYER_NAME,
DEST,
SEND_STATE,
SEND_FAIL_RESON
from meat_out_info_base
]]>
</select>
</sqlMap>

dao:
public interface MeatOutInfoBaseDao extends GenericDao<MeatOutInfoBase, String> {

}
dao.impl:
public class MeatOutInfoBaseDaoImpl extends GenericDaoImpl<MeatOutInfoBase, String> implements MeatOutInfoBaseDao {

}
service:
@WebService
public interface MeatOutInfoBaseService extends GenericService<MeatOutInfoBase,String> {
//public boolean Login(String userName, String password);
}
service.impl:
@WebService(endpointInterface = "com.sunraw.kunming.service.MeatOutInfoBaseService")
public class MeatOutInfoBaseServiceImpl extends GenericServiceImpl<MeatOutInfoBase, String> implements MeatOutInfoBaseService {

private MeatOutInfoBaseDao meatOutInfoBaseDao;

public void setMeatOutInfoBaseDao(MeatOutInfoBaseDao meatOutInfoBaseDao) {  
        this.meatOutInfoBaseDao = meatOutInfoBaseDao;  
    }

public GenericDao<MeatOutInfoBase, String> getDao(){
return meatOutInfoBaseDao;
}
}


错误提示:
xception in thread "main" com.ibatis.sqlmap.client.SqlMapException: There is no statement named selectSQL in this SqlMap.
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.getMappedStatement(SqlMapExecutorDelegate.java:293)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:606)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:589)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:118)
at org.springframework.orm.ibatis.SqlMapClientTemplate$3.doInSqlMapClient(SqlMapClientTemplate.java:298)
at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:209)
at org.springframework.orm.ibatis.SqlMapClientTemplate.executeWithListResult(SqlMapClientTemplate.java:249)
at org.springframework.orm.ibatis.SqlMapClientTemplate.queryForList(SqlMapClientTemplate.java:296)
at org.springframework.orm.ibatis.SqlMapClientTemplate.queryForList(SqlMapClientTemplate.java:290)
at com.sunraw.rock.dao.impl.GenericDaoImpl.select(GenericDaoImpl.java:157)
at com.sunraw.test.Tests.TestDao(Tests.java:48)
at com.sunraw.test.Tests.main(Tests.java:19)
上面红色标记处明明有selectSQL,为什么会提示这个错误呢?
[解决办法]
对ibatis不熟悉,和<sqlMap namespace="MeatOutInfoBase">

这句有关系没?
[解决办法]
mybatis的namespace都是写成对应的接口
[解决办法]
检查下GenericDaoImpl.java:157

There is no statement named selectSQL in this SqlMap

没用过mybatis,大概是没有在sqlMap中定义selectSQL 
[解决办法]
CDATA 部分中的所有内容都会被解析器忽略。


[解决办法]
你在dao.impl里面的构造函数里面加上这句:
super.setSqlmapNamespace("MeatOutInfoBase.");

SqlMapConfig.xml里面加上:
<settings cacheModelsEnabled="true" enhancementEnabled="true"
lazyLoadingEnabled="true" maxRequests="200" maxSessions="100"
maxTransactions="20" useStatementNamespaces="true" />
这样应该可行的

热点排行