Ibatis(Oracle) recuperar un cursor desde un procedure
Estoy intentando hacer un pequeño ejemplo para recuperar con ibatis desde java un cursor de un procedimiento de oracle, pero no consigo que funcione, mi ejemplo es el siguiente:
Mi procedimiento:
create or replace procedure "PRUEBAS".datos_empleados
(
Par1 IN VARCHAR2,
cursor1 OUT empleados_pkg.empleados_type
)
AS
Begin
/* tiene valor par1 */
IF par1 IS NOT NULL
THEN
OPEN cursor1 FOR
SELECT * FROM EMPLOYEES
WHERE NAME = par1;
/* no tiene valor */
ELSE
OPEN cursor1 FOR
SELECT * FROM EMPLOYEES;
END IF;
END datos_empleados;
Mi sqlMap:
PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-2.dtd">
{call datos_empleados(?,?)}
Mi forma de llamarlo desde java:
private static final String NAME_SPACE_cursor = "certificadosCursor.";
private static final String GET_CERTIF_MYLISTCURSOR_NIF = "getMiListaNifCursor";
Map map = new HashMap(1);
System.out.println("getMiListaNifCursor: "+theNombre);
map.put(MAP_par1,theNombre);
sqlMapClient.queryForList(NAME_SPACE_cursor+GET_CERTIF_MYLISTCURSOR_NIF,map);
emps = (ArrayList)map.get("cursor1");
System.out.println("emps: "+emps);
El error que saca es:
Constructor CertificacionesBO
Trying to load ibatis configuration file maps/sql-map-config-certificados.xml
Ibatis Configuration loaded
GetMiListaNifCursor: angel
SQLException getMiListaNifCursor
Capturada SQLException:
--- The error occurred in maps/certificadosCursor.xml.
--- The error occurred while applying a parameter map.
--- Check the certificadosCursor. NifPar.
--- Check the output parameters (retrieval of output parameters failed).
--- Cause: java. Lang. NullPointerException
com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in maps/certificadosCursor.xml.
--- The error occurred while applying a parameter map.
--- Check the certificadosCursor. NifPar.
--- Check the output parameters (retrieval of output parameters failed).
--- Cause: java. Lang. NullPointerException
Caused by: java. Lang. NullPointerException
At com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:188)
At com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForList(GeneralStatement.java:123)
At com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:610)
At com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:584)
At com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:101)
At com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForList(SqlMapClientImpl.java:78)
At com.dao.certificados.CertificadosIbatisDAO.getMiListaNifCursor(CertificadosIbatisDAO.java:80)
At com.bo.certificados.CertificacionesBO.getMiListaNifCursor(CertificacionesBO.java:48)
At main. CertificadosCursor.main(CertificadosCursor.java:29)
Caused by: java. Lang. NullPointerException
At com.ibatis.sqlmap.engine.execution.SqlExecutor.retrieveOutputParameters(SqlExecutor.java:354)
At com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQueryProcedure(SqlExecutor.java:301)
At com.ibatis.sqlmap.engine.mapping.statement.ProcedureStatement.sqlExecuteQuery(ProcedureStatement.java:34)
At com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:173)
... 8 more
Caused by:
java. Lang. NullPointerException
At com.ibatis.sqlmap.engine.execution.SqlExecutor.retrieveOutputParameters(SqlExecutor.java:354)
At com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQueryProcedure(SqlExecutor.java:301)
At com.ibatis.sqlmap.engine.mapping.statement.ProcedureStatement.sqlExecuteQuery(ProcedureStatement.java:34)
At com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:173)
At com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForList(GeneralStatement.java:123)
At com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:610)
At com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:584)
At com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:101)
At com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForList(SqlMapClientImpl.java:78)
At com.dao.certificados.CertificadosIbatisDAO.getMiListaNifCursor(CertificadosIbatisDAO.java:80)
At com.bo.certificados.CertificacionesBO.getMiListaNifCursor(CertificacionesBO.java:48)
At main. CertificadosCursor.main(CertificadosCursor.java:29)
Caused by:
java. Lang. NullPointerException
At com.ibatis.sqlmap.engine.execution.SqlExecutor.retrieveOutputParameters(SqlExecutor.java:354)
At com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQueryProcedure(SqlExecutor.java:301)
At com.ibatis.sqlmap.engine.mapping.statement.ProcedureStatement.sqlExecuteQuery(ProcedureStatement.java:34)
At com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:173)
At com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForList(GeneralStatement.java:123)
At com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:610)
At com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:584)
At com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:101)
At com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForList(SqlMapClientImpl.java:78)
At com.dao.certificados.CertificadosIbatisDAO.getMiListaNifCursor(CertificadosIbatisDAO.java:80)
At com.bo.certificados.CertificacionesBO.getMiListaNifCursor(CertificacionesBO.java:48)
At...
Mi procedimiento:
create or replace procedure "PRUEBAS".datos_empleados
(
Par1 IN VARCHAR2,
cursor1 OUT empleados_pkg.empleados_type
)
AS
Begin
/* tiene valor par1 */
IF par1 IS NOT NULL
THEN
OPEN cursor1 FOR
SELECT * FROM EMPLOYEES
WHERE NAME = par1;
/* no tiene valor */
ELSE
OPEN cursor1 FOR
SELECT * FROM EMPLOYEES;
END IF;
END datos_empleados;
Mi sqlMap:
PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-2.dtd">
{call datos_empleados(?,?)}
Mi forma de llamarlo desde java:
private static final String NAME_SPACE_cursor = "certificadosCursor.";
private static final String GET_CERTIF_MYLISTCURSOR_NIF = "getMiListaNifCursor";
Map map = new HashMap(1);
System.out.println("getMiListaNifCursor: "+theNombre);
map.put(MAP_par1,theNombre);
sqlMapClient.queryForList(NAME_SPACE_cursor+GET_CERTIF_MYLISTCURSOR_NIF,map);
emps = (ArrayList)map.get("cursor1");
System.out.println("emps: "+emps);
El error que saca es:
Constructor CertificacionesBO
Trying to load ibatis configuration file maps/sql-map-config-certificados.xml
Ibatis Configuration loaded
GetMiListaNifCursor: angel
SQLException getMiListaNifCursor
Capturada SQLException:
--- The error occurred in maps/certificadosCursor.xml.
--- The error occurred while applying a parameter map.
--- Check the certificadosCursor. NifPar.
--- Check the output parameters (retrieval of output parameters failed).
--- Cause: java. Lang. NullPointerException
com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in maps/certificadosCursor.xml.
--- The error occurred while applying a parameter map.
--- Check the certificadosCursor. NifPar.
--- Check the output parameters (retrieval of output parameters failed).
--- Cause: java. Lang. NullPointerException
Caused by: java. Lang. NullPointerException
At com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:188)
At com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForList(GeneralStatement.java:123)
At com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:610)
At com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:584)
At com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:101)
At com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForList(SqlMapClientImpl.java:78)
At com.dao.certificados.CertificadosIbatisDAO.getMiListaNifCursor(CertificadosIbatisDAO.java:80)
At com.bo.certificados.CertificacionesBO.getMiListaNifCursor(CertificacionesBO.java:48)
At main. CertificadosCursor.main(CertificadosCursor.java:29)
Caused by: java. Lang. NullPointerException
At com.ibatis.sqlmap.engine.execution.SqlExecutor.retrieveOutputParameters(SqlExecutor.java:354)
At com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQueryProcedure(SqlExecutor.java:301)
At com.ibatis.sqlmap.engine.mapping.statement.ProcedureStatement.sqlExecuteQuery(ProcedureStatement.java:34)
At com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:173)
... 8 more
Caused by:
java. Lang. NullPointerException
At com.ibatis.sqlmap.engine.execution.SqlExecutor.retrieveOutputParameters(SqlExecutor.java:354)
At com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQueryProcedure(SqlExecutor.java:301)
At com.ibatis.sqlmap.engine.mapping.statement.ProcedureStatement.sqlExecuteQuery(ProcedureStatement.java:34)
At com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:173)
At com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForList(GeneralStatement.java:123)
At com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:610)
At com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:584)
At com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:101)
At com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForList(SqlMapClientImpl.java:78)
At com.dao.certificados.CertificadosIbatisDAO.getMiListaNifCursor(CertificadosIbatisDAO.java:80)
At com.bo.certificados.CertificacionesBO.getMiListaNifCursor(CertificacionesBO.java:48)
At main. CertificadosCursor.main(CertificadosCursor.java:29)
Caused by:
java. Lang. NullPointerException
At com.ibatis.sqlmap.engine.execution.SqlExecutor.retrieveOutputParameters(SqlExecutor.java:354)
At com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQueryProcedure(SqlExecutor.java:301)
At com.ibatis.sqlmap.engine.mapping.statement.ProcedureStatement.sqlExecuteQuery(ProcedureStatement.java:34)
At com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:173)
At com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForList(GeneralStatement.java:123)
At com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:610)
At com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:584)
At com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:101)
At com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForList(SqlMapClientImpl.java:78)
At com.dao.certificados.CertificadosIbatisDAO.getMiListaNifCursor(CertificadosIbatisDAO.java:80)
At com.bo.certificados.CertificacionesBO.getMiListaNifCursor(CertificacionesBO.java:48)
At...
2 respuestas
Respuesta de khanser
1
Respuesta de jclaveria