[
http://issues.apache.org/jira/browse/IBATIS-53?page=comments#action_12365398 ]
Mohamed Arif commented on IBATIS-53:
------------------------------------
Hi,
I am new to Ibatis and trying Ibatis SQL Map for replacing Spring
DAO.
Can any one let me know, is the Bug "IBATIS-53" resolved in any
other version of Ibatis ? If yes, pls let me know the version no and where it
can be downloaded.
I am trying Ibatis SQL using spring, and
As suggested by Ken, I made the code change in
SQLExecutor.executeQueryProcedure, but still getting the following exception,
--- The error occurred in Account.xml.
--- The error occurred while applying a parameter map.
--- Check the Account.accountSPInput.
--- Check the output parameters (retrieval of output parameters failed).
--- Cause: java.lang.NullPointerException; nested exception is
com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in Account.xml.
--- The error occurred while applying a parameter map.
--- Check the Account.accountSPInput.
--- Check the output parameters (retrieval of output parameters failed).
--- Cause: java.lang.NullPointerException], value class [java.lang.String], SQL
type 12
[DEBUG] 2006-02-07 11:29:46,899 jdbc.datasource.DataSourceUtils - Returning
JDBC Connection to DataSource
Below are the configuration files and other related files,
Spring Configuration XML :
<bean id="AccountDAO"
class="com.rsa.rcas.common.dao.ibatisImpl.IbatisAccountDAOImpl">
<property name="dataSource"><ref local="RCASDataSource"/></property>
<property name="sqlMapClient"><ref local="sqlMapClient"/></property>
</bean>
<bean id="sqlMapClient"
class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation">
<value>ibatisConfig.xml</value>
</property>
</bean>
<!--Defines the Transaction Manager-->
<bean id="TransactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource">
<ref bean="RCASDataSource"></ref>
</property>
</bean>
<!--Data Source-->
<bean id="RCASDataSource"
class="org.springframework.jndi.JndiObjectFactoryBean" lazy-init="true">
<property name="jndiName">
<value>RCASDev</value>
</property>
</bean>
Ibatis Configuration XML:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMapConfig
PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN"
"http://www.ibatis.com/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
<sqlMap resource="Account.xml"/>
</sqlMapConfig>
Account.xml :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap
PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN"
"http://www.ibatis.com/dtd/sql-map-2.dtd">
<sqlMap namespace="Account">
<typeAlias alias="account" type="com.rsa.rcas.common.dto.Account"/>
<typeAlias alias="accountDeviceDetail"
type="com.rsa.rcas.common.dto.AccountDeviceDetail"/>
<resultMap id="accountResult" class="accountDeviceDetail">
<result property="accountId" column="ACC_ID" />
<result property="status" column="ACC_STA" />
<result property="deviceID" column="D_ID" />
<result property="deviceStatus" column="D_STA" />
<result property="createdDate" column="CRT_DAT" />
<result property="nickName" column="NK_NA" />
<result property="authenticatorId" column="AUT_ID" />
<result property="authenticatorStatus" column="AUT_STA" />
<result property="expiryDate" column="EXP_DATE" />
<result property="last4DigitsSerNum" column="LTFR_DIGIT_SN" />
<result property="privateData" column="PT_DATA" />
<result property="serialNumber" column="SL_NUM" />
</resultMap>
<parameterMap id="accountSPInput" class="map" >
<parameter property="PA_IN_ACCOUNTID" jdbcType="long"
javaType="java.lang.Long" mode="IN"/>
<parameter property="PA_IN_SITEID" jdbcType="long"
javaType="java.lang.Long" mode="IN"/>
<parameter property="PA_OUT_RETCURSOR" jdbcType="ORACLECURSOR"
javaType="java.sql.ResultSet" mode="OUT"/>
</parameterMap>
<procedure id="getAccountDetail" parameterMap="accountSPInput"
resultMap="accountResult">
{ call PR_RS_GET_ACC_DETAILS (?, ?, ?) }
</procedure>
</sqlMap>
My Stored Procedure :
CREATE OR REPLACE PROCEDURE PR_RS_GET_ACC_DETAILS (
PA_IN_ACCOUNTID IN NUMBER,
PA_IN_SITEID IN NUMBER,
PA_OUT_RETCURSOR OUT RS_GENERAL.REFCURSOR
)
IS
/BEGIN
OPEN PA_OUT_RETCURSOR FOR
SELECT ACC.ACCOUNT_ID AS ACCOUNT_ID,
ACC.STATUS AS ACC_STA,
DEV.D_ID AS D_ID,
DEV.STA AS D_STA,
DEV.CRT_DATE AS CRT_DATE,
DEV.NK_NA AS NK_NA,
AUT.AUT_ID AS AUT_ID,
AUT.STA AS AUT_STA,
AUT.EXP_DATE AS EXP_DATE,
AUT.LT_FRDIGIT_SN AS LTFR_DIGIT_SN,
AUT.PT_DATA AS PT_DATA,
AUT.SL_NUM
FROM RS_ANT_MST AC,
RS_DE_MST DEV,
RS_AUT_MST AUT
WHERE ACC.ACC_ID = DEV.ACC_ID
AND AUT.AUT_ID = DEV.AUT_ID
AND DEV.ACC_ID = PA_IN_ACCOUNTID
AND ACC.SITE_ID = PA_IN_SITEID;
END PR_RS_GET_ACC_DETAILS;
/
Kindly, just me what changes to be done and if any latest Ibatis jar to be
used.
Currently, i am using "iBATIS_DBL-2.1.7.597.zip" downloaded from ibatis site.
Regards,
RF
> Support for oracle cursors as resultsets
> ----------------------------------------
>
> Key: IBATIS-53
> URL: http://issues.apache.org/jira/browse/IBATIS-53
> Project: iBatis for Java
> Type: New Feature
> Components: SQL Maps
> Reporter: Ken Katsma
> Priority: Minor
> Fix For: 2.1.0
> Attachments: SqlExecutor.java, SqlExecutor.java, SqlExecutor.java,
> SqlExecutor.java, showcase.txt, showcase_storedprocedure.txt,
> showcase_storedprocedure1.txt
>
> iBatis doesn't currently support result sets from functions in Oracle. A
> modification to SQLExecutor as detailed below can add the necessary support.
> However, it requires a hard-coded check for an Oracle driver. A better
> option would be to supply a factory for alternate SQLExecutor's for different
> dialects. This would allow for any future database specific customization as
> well.
> The code change is in SQLExecutor.executeQueryProcedure (see comments):
> public void executeQueryProcedure(RequestScope request, Connection conn,
> String sql, Object[] parameters,
> int skipResults, int maxResults,
> RowHandlerCallback callback)
> throws SQLException {
> ErrorContext errorContext = request.getErrorContext();
> errorContext.setActivity("executing query procedure");
> errorContext.setObjectId(sql);
> CallableStatement cs = null;
> ResultSet rs = null;
> try {
> errorContext.setMoreInfo("Check the SQL Statement (preparation
> failed).");
> cs = conn.prepareCall(sql);
> ParameterMap parameterMap = request.getParameterMap();
> ParameterMapping[] mappings = parameterMap.getParameterMappings();
> errorContext.setMoreInfo("Check the output parameters (register output
> parameters failed).");
> registerOutputParameters(cs, mappings);
> errorContext.setMoreInfo("Check the parameters (set parameters
> failed).");
> parameterMap.setParameters(request, cs, parameters);
> errorContext.setMoreInfo("Check the statement (update procedure
> failed).");
> // ****************************************
> // Code changes below
> // ****************************************
> if
> (conn.getMetaData().getDatabaseProductName().equalsIgnoreCase("Oracle"))
> {
> // If in oracle then execute instead of executeQuery
> boolean b = cs.execute();
> errorContext.setMoreInfo("In Oracle query mode.");
> errorContext.setMoreInfo("Check the output parameters (retrieval of
> output parameters failed).");
> // Get the output parameters first, instead of last
> retrieveOutputParameters(cs, mappings, parameters);
> // Then find the resultset and handle it
> for (int i=0;i<parameters.length;i++)
> {
> if (parameters[i] instanceof ResultSet)
> {
> rs = (ResultSet) parameters[i];
> break;
> }
> }
> errorContext.setMoreInfo("Check the results (failed to retrieve
> results).");
> handleResults(request, rs, skipResults, maxResults, callback);
> }
> //****************************************
> // Non-oracle..original code
> else
> {
>
> errorContext.setMoreInfo("In non-Oracle mode.");
> rs = cs.executeQuery();
> errorContext.setMoreInfo("Check the results (failed to retrieve
> results).");
> handleResults(request, rs, skipResults, maxResults, callback);
> errorContext.setMoreInfo("Check the output parameters (retrieval of
> output parameters failed).");
> retrieveOutputParameters(cs, mappings, parameters);
> }
> } finally {
> try {
> closeResultSet(rs);
> } finally {
> closeStatement(cs);
> }
> }
> An example mapping looks like:
> <parameterMap id="clientParameters" class="map" >
> <parameter property="result" jdbcType="ORACLECURSOR" mode="OUT"/>
> <parameter property="maxRows" jdbcType="VARCHAR"
> javaType="java.lang.String" mode="IN"/>
> </parameterMap>
> <procedure id="getClientListProc" resultMap="clientResult"
> parameterMap="clientParameters">
> {?= call abc.CLIENT_VIEW_PKG.client_result_list_f(?)}
> </procedure>
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira