【发布时间】:2017-04-29 21:58:17
【问题描述】:
我在 Oracle 中调用一个存储过程,它接收 7 个参数并返回 5 个,我只对两个参数感兴趣。 这是我的 MyBatis 选择
@Select(value = "{CALL prc_ultimo_nombramiento(" +
"#{tipoIdentificacion, mode=IN}," +
"#{numeroIdentificacion, mode=IN}," +
"#{idEt, jdbcType=VARCHAR}," +
"#{fechaPosesion, mode=OUT, jdbcType=VARCHAR}," +
"#{idTipoNombramiento, mode=OUT, jdbcType=VARCHAR}," +
"#{validar, jdbcType=VARCHAR}," +
"#{mensaje, jdbcType=VARCHAR}" +
")}")
@Options(statementType = StatementType.CALLABLE)
@ResultType(CPDatosDocente.class)
CPDatosDocente obtenerDatosFechaPosesionIdNombramiento(CPDatosDocente datosDocente);
我的 CPDatosDocente 是一个 POJO,它包含我需要的所有变量。
String idTipoNombramiento;
String validar;
String mensaje;
String fechaPosesion;
String tipoIdentificacion;
String numeroIdentificacion;
String idEt;
//Getters and setters...
我有一个调用 MyBatis Sentence 的 dao,但是当我调用过程时,我的 object(CPDatosDocente) 为 null
public CPDatosDocente obtenerFechaPosesionIdNombramiento(Long tipoIdentificacion,
Long numeroIdentificacionDocente) {
SqlSession session = sf.openSession();
try {
// Se abre conexión con el mapper
CPDatosDocenteMapper mapper = session.getMapper(CPDatosDocenteMapper.class);
// Se ejecuta la consulta para obtener la fecha de posesión y el
// tipo de nombramiento
CPDatosDocente datos = new CPDatosDocente();
datos.setTipoIdentificacion(tipoIdentificacion);
datos.setNumeroIdentificacion(numeroIdentificacionDocente);
CPDatosDocente datosDocente = mapper.obtenerDatosFechaPosesionIdNombramiento(datos);
System.out.println(datosDocente.getFechaPosesion());
return datosDocente;
} finally {
session.close();
}
}
我尝试了很多东西,但我无法获得我需要的带有参数 OUT 的对象。
【问题讨论】:
-
您是否收到任何错误消息?除此之外,您说有 5 个 OUT 参数,但您只提供了 2 个。尝试提供所有 5 个参数,即使您只使用其中的 2 个。 Oracle 必须接收与过程签名匹配的过程调用。
标签: java oracle stored-procedures mybatis