Java d of resultType=“PetDVO”,但我不记得在映射器文件中的任何地方看到了petData映射?我稍后再查。谢谢。我还是很困惑,因为您正在执行resultType,这意味着您希望callReadAllPets返回一个值,但您没有从getSql
Java d of resultType=“PetDVO”,但我不记得在映射器文件中的任何地方看到了petData映射?我稍后再查。谢谢。我还是很困惑,因为您正在执行resultType,这意味着您希望callReadAllPets返回一个值,但您没有从getSql,java,mybatis,Java,Mybatis,d of resultType=“PetDVO”,但我不记得在映射器文件中的任何地方看到了petData映射?我稍后再查。谢谢。我还是很困惑,因为您正在执行resultType,这意味着您希望callReadAllPets返回一个值,但您没有从getSqlSession()获取返回值。selectList(。相反,您似乎希望它出现在parameter对象中,而实际上不存在任何OUT参数…如果您实际上不希望从selectList返回某些内容,那么您不需要映射器中的returnType…那么语句中的
d of resultType=“PetDVO”,但我不记得在映射器文件中的任何地方看到了petData映射?我稍后再查。谢谢。我还是很困惑,因为您正在执行resultType,这意味着您希望callReadAllPets返回一个值,但您没有从
getSqlSession()获取返回值。selectList(
。相反,您似乎希望它出现在parameter对象中,而实际上不存在任何OUT参数…如果您实际上不希望从selectList返回某些内容,那么您不需要映射器中的returnType…那么语句中的OUT参数就足够了。因此我假设您只需要List outputData=getSqlSession().selectList(“callReadAllPets”,inputMap);
这里。是的,我知道我可以用这种方法解决问题,而且我以前做过很多次,但我想知道书中给出的解决方案。为什么不起作用,以及如何使它起作用?不,resultMap=“petData”
不起作用。我将坚持使用列表outputData=getSqlSession()。selectList(“callReadAllPets”,inputMap)
因为它可以完美地工作。不,resultMap=“petData”
不起作用。我将坚持使用列表outputData=getSqlSession()。selectList(“callReadAllPets”,inputMap)
因为它可以完美地工作。
public void callReadAllPets() throws Exception {
HashMap<String, List<PetDVO>> inputMap = new HashMap<String, List<PetDVO>>();
List<PetDVO> petList = new ArrayList<PetDVO>();
inputMap.put("petData", petList);
//
getSqlSession().selectList("callReadAllPets", inputMap);
List<PetDVO> outputData = inputMap.get("petData");
printResultList(outputData, "read_all_pets");
}
private void printResultList(List<PetDVO> list) {
for (PetDVO item : list) {
System.out.println(" owner: " + item.getOwner());
System.out.println(" species: " + item.getSpecies());
System.out.println(" sex: " + item.getSex());
}
}
<select id="callReadAllPets" resultType="PetDVO" statementType="CALLABLE">
CALL read_all_pets('SELECT name, owner, species, sex, birth, death FROM pet')
<mapper namespace="com.example.SomeMapper">
<select id="doSomething" statementType="CALLABLE" parameterType="com.example.SomeRequest">
{ call someProcedure (
#{someParameter,javaType=Long,jdbcType=NUMERIC,mode=IN},
#{out,javaType=Long,jdbcType=NUMERIC,mode=OUT})
}
</select >
</mapper>
class SomeRequest {
private Long someParameter;
private Long out;
// add Getters & Setters
}