Java Mailing List Archive

http://www.java2.5341.com/

Home » user-java.ibatis »

Select from View (as opposed to table) using iBatis

mule_user

2010-06-09

Replies: Find Java Web Hosting

Author LoginPost Reply

I am using iBatis (2.5) with DB2 version 8.x and Spring 2.5. Is there any
issue in querying a view (as opposed to table)? It is a very simple select
as:

<resultMap id="codeMap" class="org.impl.CodeBean">
    <result column="TBL_NM"    property="tableName"
typeHandler="org.our.StringTrimTypeHandler"/>
    <result column="COL_NM"   property="columnName"
typeHandler="org.our.StringTrimTypeHandler"/>
    <result column="CD"        property="code"    
typeHandler="org.our.StringTrimTypeHandler"/>
    <result column="CD_DESC"  property="shortDesc"
typeHandler="org.our.StringTrimTypeHandler"/>
    <result column="CD_LNG_DESC" property="longDesc"
typeHandler="org.our.StringTrimTypeHandler"/>
</resultMap>

<select id="findAll" resultMap="codeMap">
    select CD from ${jdbc.schema}.V_MY_VIEW
</select>


org.impl.CodeBean is a simple POJO with String attributes only with public
getter and setter. StringTrimTypeHandler are custom code written.

My SQL are working when I am using table, as opposed to View.

When I call the above findAll from JUnit for View, I get exception as:


--   Exception: org.springframework.jdbc.BadSqlGrammarException: SQL
MAPPING ID: code.findAll; bad SQL grammar []; nested exception is
com.ibatis.common.jdbc.exception.NestedSQLException:  

--- The error occurred in org/.../mapping/code.xml.

--- The error occurred while applying a parameter map.

--- Check the code.findAll-InlineParameterMap.

--- Check the statement (query failed).

--- Cause: com.ibm.db2.jcc.c.SqlException: DB2 SQL error: SQLCODE: -204,
SQLSTATE: 42704, SQLERRMC: MY_SCHEMA.V_MY_VIEW

--   Exception Detail:
com.ibatis.common.jdbc.exception.NestedSQLException:  

--- The error occurred in org/.../mapping/code.xml.

I must be missing something.

Query from View is supported in iBatis, correct?
--
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@(protected)
For additional commands, e-mail: user-java-help@(protected)

©2008 java2.5341.com - Jax Systems, LLC, U.S.A.