Please join us at the new project site: www.mybatis.org Select from view is support. The error message is "Undefined Name". DB2 cannot find the view called MY_SCHEMA.V_MY_VIEW.
Jeff Butler On Wed, Jun 9, 2010 at 4:11 PM, mule_user <s...@aol.com> wrote: > > 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? > -- > View this message in context: > http://old.nabble.com/Select-from-View-%28as-opposed-to-table%29-using-iBatis-tp28835900p28835900.html > Sent from the iBATIS - User - Java mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-java-unsubscr...@ibatis.apache.org > For additional commands, e-mail: user-java-h...@ibatis.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-java-unsubscr...@ibatis.apache.org For additional commands, e-mail: user-java-h...@ibatis.apache.org