關於對映語句集合不包含com.itheima.ssm.IMemberDao.findById的值的異常
異常中文翻譯如下:
查詢資料庫時出錯。原因:. lang。對映語句集合不包含com.itheima.ssm.IMemberDao.findById的值
這個錯誤可能存在於com/itheima/ssm/dao/ITravellerDao中。java(猜測)
這個錯誤可能涉及com.itheima.ssm.dao.ITravellerDao.findByOrdersId
在處理結果時發生錯誤
### SQL: select * from Traveller where id in(從order_traveller中選擇travellerId where orderId=?)
# # #原因:. lang。IllegalArgumentException:對映語句集合不包含com.itheima.ssm.IMemberDao的值。帶有根本原因的findById]
. lang。對映語句集合不包含com.itheima.ssm.IMemberDao.findById的值
org.apache.ibatis.session.Configuration StrictMap.get美元(Configuration.java:888)
org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:721)
org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:714)
程式碼如下:
@Select("select * from orders where id=#{id}")
@Results({
@Result(id=true,column = "id",property = "id"),
@Result(property = "orderNum",column = "orderNum"),
@Result(property = "orderTime",column = "orderTime"),
@Result(column = "orderStatus",property = "orderStatus"),
@Result(column = "peopleCount",property = "peopleCount"),
@Result(column = "payType",property = "payType"),
@Result(column = "orderDesc",property = "orderDesc"),
@Result(column = "productId",property ="product",javaType = Product.class,
one = @One(select = "com.itheima.ssm.dao.IProductDao.findById")),
@Result(column = "id",property = "travellers",javaType = java.util.List.class,
many = @Many(select = "com.itheima.ssm.dao.ITravellerDao.findByOrdersId")),
@Result(column ="memberId",property = "member",javaType = Member.class,
[email protected](select="com.itheima.ssm.IMemberDao.findById"))
})
Orders findById(String id);
}
這個異常是我用對映做表查詢的時候遇到的,表與表關係是多對多關係,上面英文說的大概就是對映語句不包含某個方法的值,其實這個異常很簡單,,出錯的原因就是上面倒數第二行程式碼中select指定的方法少寫了一個包名稱,導致Mybatis對映不到
IMemberDao介面中我要執行的方法,所以才會報這個錯誤,很低階的一個錯誤,但是對於我這個新手來說在這麼多程式碼中找這個異常還是花了不少時間.發出來幫助比我還馬虎的網友...