I'm trying to call the child mapper method by a flexible case But in this case, we don't know which method will be called even it extends parent mapper. [spring boot framework with mybatis]
// ParentMapper
public interface ParentMapper
{
// List<Map<String, String> findAll();
}
// Child1Mapper
public interface Child1Mapper extends ParentMapper
{
List<Map<String, String> findAll();
}
// Child2Mapper
public interface Child2Mapper extends ParentMapper{
List<Map<String, String> findAll();
}
@Autowired
Child1Mapper child1Mapper;
@Autowired
Child2Mapper child2Mapper;
// some class file
public ParentMapper getMapper(String param){
switch(param){
case "case1" : child1Mapper;
case "case2" : child2Mapper;
... 10 more..
}
}
public class example{
public void somethid(){
// this logic is in some biz
ParentMapper mapper = getMapper("case1"); // <----`-` we do not know where `findAll method` located is in
mapper.findAll();
}
}
how to call the child mapper method