CatalogDao中方法参数的疑问
以下是CatalogDao.java代码,其中最后一个方法( List<Catalog> selectByPid(int pid);)的参数在业务层是
如何拿到的,业务层并没有显示调用该方法。请详细解释一下该方法的执行机制,谢谢!
package com.imooc.icake.dao;
import com.imooc.icake.entity.Catalog;
import org.apache.ibatis.annotations.*;
import java.util.List;
public interface CatalogDao {
@Insert("<script>" +
"insert catalog(title,pid,info) values"+
"<foreach collection='list' item='catalog' separator=',' >" +
"(#{catalog.title},#{catalog.pid},#{catalog.info})"+
"</foreach>"+
"</script>")
@Options(useGeneratedKeys = true,keyProperty = "id")
void batchInsert(List<Catalog> list);
@Delete("delete from catalog where id=#{id}")
void delete(int id);
@Select("select * from catalog where id=#{id}")
@Results(id = "all",value = {
@Result(column = "id",property ="id",id = true),
@Result(column = "title",property = "title"),
@Result(column = "pid",property = "pid"),
@Result(column = "info",property = "info"),
@Result(column = "id",property = "children",many=@Many(select = "selectByPid") )
})
Catalog select(int id);
@Select("select * from catalog where pid=#{pid}")
@ResultMap("all")
List<Catalog> selectByPid(int pid);
}
正在回答 回答被采纳积分+1
- 参与学习 人
- 提交作业 277 份
- 解答问题 4297 个
Java数据库开发的必备技能,从流行的MySQL数据库开始,到Java原生的数据库管理接口JDBC的使用,再到常用的数据持久化框架MyBatis,让你向Java工程师的目标又迈进了一步!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星