[ 
http://issues.apache.org/jira/browse/IBATIS-156?page=comments#action_12365722 ] 

Mohamed Arif commented on IBATIS-156:
-------------------------------------


Hi,
       I am trying to work on TypeHandler as one of the column returned by my 
ResultSet is of type "CHAR".

       I am getting the following exception w.r.t TypeHandler,

--- The error occurred in Policy.xml.  
--- The error occurred while applying a result map.  
--- Check the Policy.customerPolicyResult.  
--- Check the result mapping for the 'attValue' property.  
--- Cause: com.ibatis.sqlmap.client.SqlMapException: No type handler could be 
found to map the property 'attValue' to the column 'POLICY_ATTRIBUTE_VALUE'.  
One or both of the types, or the combination of types is not supported.; nested 
exception is com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred in Policy.xml.  
--- The error occurred while applying a result map.  
--- Check the Policy.customerPolicyResult.  
--- Check the result mapping for the 'attValue' property.

   Here are the configuration details,

My Stored Procedure is,
CREATE OR REPLACE PROCEDURE PR_RS_GET_POLICY_DETAILS (
    PA_OUT_RETCURSOR          OUT      RS_GENERAL.REFCURSOR
)
AS

BEGIN
    OPEN PA_OUT_RETCURSOR FOR
        SELECT   DET.CUSTOMER_ID as CUSTOMER_ID,
                 DET.POLICY_ID as POLICY_ID,
                 DET.POLICY_ATTRIBUTE_VALUE as POLICY_ATTRIBUTE_VALUE,
                 EXCEP.RELATED_CUSTOMER_ID as RELATED_CUSTOMER_ID
        FROM     RS_POLICY_DET DET,
                 RS_POLICY_EXCEPTIONLIST_DET EXCEP
        WHERE    DET.POLICY_ID = EXCEP.POLICY_ID(+)
        AND      DET.CUSTOMER_ID = EXCEP.CUSTOMER_ID(+)
        ORDER BY DET.CUSTOMER_ID,
                 DET.POLICY_ID;
END PR_RS_GET_POLICY_DETAILS;
/


***** > Here the column "POLICY_ATTRIBUTE_VALUE" is of type "CHAR".

My SQLMapConfig file is as follow,
*************************************

<?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>

<typeAlias alias="charTypeHandler" 
type="com.rss.rs.common.dao.ibatisImpl.CharTypeHandlerCallback"/>

<typeHandler javaType="java.lang.String" jdbcType="CHAR" 
callback="charTypeHandler"/>

<sqlMap resource="Policy.xml"/>
        
</sqlMapConfig>

***********************************
My SQLMap file "Policy.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="Policy">

<typeAlias alias="policyRS" type="com.rsa.rcas.common.dto.PolicyRS"/>

<resultMap id="customerPolicyResult" class="policyRS">
        <result property="customerID" column="CUSTOMER_ID" />
        <result property="policyID" column="POLICY_ID" />
        <result property="attValue" column="POLICY_ATTRIBUTE_VALUE" 
jdbcType="CHAR"/>
        <result property="relatedCustomerid" column="RELATED_CUSTOMER_ID" />
</resultMap>

<parameterMap id="policySPInput" class="map" >
        <parameter property="PA_OUT_RETCURSOR" jdbcType="ORACLECURSOR" 
mode="OUT"/>      
</parameterMap>

<procedure id="getPolicyDetail" parameterMap="policySPInput" 
resultMap="customerPolicyResult">
{ call PR_RCAS_GET_POLICY_DETAILS (?) }
</procedure>

</sqlMap>

***************************

My TypeHandler class "CharTypeHandlerCallback.java",

import java.sql.SQLException;
import java.sql.Types;

import com.ibatis.sqlmap.client.extensions.ParameterSetter;
import com.ibatis.sqlmap.client.extensions.ResultGetter;
import com.ibatis.sqlmap.client.extensions.TypeHandlerCallback;

public class CharTypeHandlerCallback implements TypeHandlerCallback {
        
        public Object getResult(ResultGetter getter) throws SQLException {
                System.out.println("Inside getResult");
                if(getter.wasNull())
                        return null;
                
             return getter.getString();
           }
        
        public void setParameter(ParameterSetter setter, Object parameter) 
throws SQLException {
                System.out.println("Inside setParameter");
                if (parameter == null) {
            setter.setNull(Types.CHAR);
        } else {
                setter.setString((String)parameter.toString());
        }
        }
        
        public Object valueOf(String s) {
                System.out.println("Inside valueOf");
                return s;
           }

}
*************************************
ResultMap class "PolicyRS.java"

public class PolicyRS {
        
        private long customerID;
        private long policyID;
        private char attValue;
        private long relatedCustomerid;
        
        public char getAttValue() {
                return attValue;
        }
        public void setAttValue(char attValue) {
                this.attValue = attValue;
        }
        public long getCustomerID() {
                return customerID;
        }
        public void setCustomerID(long customerID) {
                this.customerID = customerID;
        }
        public long getPolicyID() {
                return policyID;
        }
        public void setPolicyID(long policyID) {
                this.policyID = policyID;
        }
        public long getRelatedCustomerid() {
                return relatedCustomerid;
        }
        public void setRelatedCustomerid(long relatedCustomerid) {
                this.relatedCustomerid = relatedCustomerid;
        }
        
}
********************

              Kindly help to solve this issue, i need to map my resultSet to 
the above class.

             Thanks in Advance,
RF



> configured type handler not used in insert
> ------------------------------------------
>
>          Key: IBATIS-156
>          URL: http://issues.apache.org/jira/browse/IBATIS-156
>      Project: iBatis for Java
>         Type: Bug
>   Components: SQL Maps
>     Versions: 2.1.0
>  Environment: linux, java 1.5
>     Reporter: Jim Newsham
>     Assignee: Clinton Begin
>     Priority: Minor
>      Fix For: 2.1.5

>
> Custom type handlers which are configured within SqlMapConfig, such as:
> <typeHandler javaType='java.lang.Boolean' jdbcType='CHAR' 
> callback='com...BooleanTypeHandler'/>
> are working properly and automatically to convert types for queries.  However 
> for inserts, the type conversion is not being called based on the above type 
> handler mapping.  We have confirmed this behavior by placing debug print 
> statements in the methods of the type handler being used.
> What does work, and what we're currently using as a workaround, is to use an 
> explicit, inline type handler within the insert map (such as 
> #private,handler=com...BooleanTypeHandler#). 

-- 
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

Reply via email to