ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian May <Brian....@noaa.gov>
Subject oracle.sql.STRUCT cannot be cast to oracle.sql.STRUCT
Date Mon, 26 Apr 2010 18:27:42 GMT
I am trying to map an Oracle type to a Java object using ibatis, but I 
am confounded by a ClassCastException. It seems like I am using the 
wrong version of the oracle.sql.STRUCT object, but I have no idea how to 
find out what version of I should be using. I currently have Ibatis 
2.3.4, ojdbc6, and Spring 3.0.2. Any help would be appreciated.

SqlMap:
<resultMap class="Object" id="attributeMap">
        <result property="attribute" javaType="Object" jdbcType="ARRAY"
            typeHandler="AttributeHandlerCallback"/>
    </resultMap>

<select id="attribute" resultMap="attributeMap">
        select
            attribute_obj(0)
        from dual
</select>

Dao:
public void getAttribute() {
    queryForObject("attribute");
)

TypeHandler:
@Override
    public Object getResult(final ResultGetter resultGetter) throws 
SQLException {
        Attribute atttribute = new attribute();
       
        try {
            final Object object = resultGetter.getObject();
            System.out.println(object.getClass());
           
            final STRUCT array = 
(oracle.sql.STRUCT)resultGetter.getObject();
        } catch (SQLException e) {
            // TODO: handle exception
            e.printStackTrace();
        }

       return attribute
}

Caused by: java.lang.ClassCastException: oracle.sql.STRUCT cannot be 
cast to oracle.sql.STRUCT
    at 
gov.noaa.ncdc.cdo.services.dao.ibatis.typehandlers.AttributeHandlerCallback.getResult(DataHandlerCallback.java:30)
    at 
com.ibatis.sqlmap.engine.type.CustomTypeHandler.getResult(CustomTypeHandler.java:58)
    at 
com.ibatis.sqlmap.engine.mapping.result.ResultMap.getPrimitiveResultMappingValue(ResultMap.java:617)
    at 
com.ibatis.sqlmap.engine.mapping.result.ResultMap.getResults(ResultMap.java:345)
    at 
com.ibatis.sqlmap.engine.execution.SqlExecutor.handleResults(SqlExecutor.java:384)
    at 
com.ibatis.sqlmap.engine.execution.SqlExecutor.handleMultipleResults(SqlExecutor.java:300)
    at 
com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java:189)
    at 
com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.sqlExecuteQuery(MappedStatement.java:221)
    at 
com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryWithCallback(MappedStatement.java:189)
    ... 46 more

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Mime
View raw message