ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andy Thompson <artho...@gmail.com>
Subject Re: ORA-00933: SQL command not properly ended
Date Fri, 17 Jun 2005 16:18:34 GMT
thanks kris.  

On 6/16/05, Kris Jenkins <krisajenkins@yahoo.co.uk> wrote:
> Hi Andy,
> 
> 'InlineParameterMap' is the name for the map that's auto-generated when
> you just supply a parameterClass.
> 
> I think your problem is in the dynamic WHERE.  Imagine this scenario:
> 
> SELECT *
> FROM table_x
> <dynamic prepend="WHERE">
>     <isNotNull prepend="AND" parameter="a">
>         ....something...
>     </isNotNull>
>     <isNotNull prepend="AND" parameter="b">
>         ....something...
>     </isNotNull>
> </dynamic>
> 
> Because 'a' and 'b' are variables, we can't know until runtime whether
> there were going to be 0, 1 or 2 clauses.  In this case we need to use
> <dynamic> to say, "whichever clause comes first - if any - make sure
> prepend use 'WHERE' instead of 'AND'".
> 
> It looks like in your case you don't need <dynamic> because you're
> always going to have at least one clause.  So you can just do this instead:
> 
>                 ...
>                 from
>                         QUESTION A,
>                         QUESTION_CONTENT B
>                 WHERE
>                         A.QUESTION_ID = B.QUESTION_ID AND
>                         B.LANGUAGE_CODE = #languageCode#
>                 <isNotNull prepend="and" property="questionId">
>                         QUESTION_ID = #questionId#
>                 </isNotNull>
> 
> 
> Hope that helps,
> Kris
> 
> mapAndy Thompson wrote:
> 
> >Problem: I think the above error is the result of some dynamic sql
> >issues.  I'm confused because when I "Check the
> >getQuestion-InlineParameterMap.  " I realize that i don't have an
> >InlineParameterMap.  If somebody wants to point me in the right
> >direction would be appreciated.
> >
> >Relevant Code:
> >}...
> >
> >protected SqlMapClient statement;
> >//build it blah blah.
> >
> >Question question = (Question) statement.queryForObject("getQuestion",
> >additionalParams);
> >...}
> >additionalParams is a HashMap containing
> >application, languageCode, and questionId
> >
> >Relevant sqlmap.xml file
> ><sqlMap namespace="Question">
> >
> >       <typeAlias type="*****blah.blah.Question******" alias="question"/>
> >       <cacheModel id="QuestionCache" type="OSCACHE"/>
> >
> >       <resultMap id="QuestionResult" class="question">
> >               <result property="id" column="QUESTION_ID"/>
> >               <result property="sortOrder" column="SORT_ORDER"/>
> >               <result property="multiAnswerString" column="MULTIPLE_ANSWER_FLAG"/>
> >               <result property="prerequisiteExpression" column="PRE_CONDITION_EXPRESSION"/>
> >               <result property="eligibilityVariablesList"
> >column="{questionId=QUESTION_ID,languageCode=LANGUAGE_CODE}"
> >select="getEligibilityVariable"/>
> >               <result property="content"
> >column="{questionId=QUESTION_ID,languageCode=LANGUAGE_CODE}"
> >select="getQuestionContent"/>
> >       </resultMap>
> >
> >  <select id="getQuestion" resultMap="QuestionResult"
> >parameterClass="java.util.HashMap" cacheModel="QuestionCache">
> >               select
> >                       A.QUESTION_ID,
> >                       A.QUESTION_GROUP_ID,
> >                       A.PRE_CONDITION_EXPRESSION,
> >                       A.MULTIPLE_ANSWER_FLAG,
> >                       A.SORT_ORDER,
> >                       #languageCode# as LANGUAGE_CODE
> >               from
> >                       QUESTION A,
> >                       QUESTION_CONTENT B
> >                       <dynamic prepend="WHERE">
> >                               A.QUESTION_ID = B.QUESTION_ID AND
> >                               B.LANGUAGE_CODE = #languageCode#
> >                       <isNotNull prepend="and" property="questionId">
> >                       QUESTION_ID = #questionId#
> >                       </isNotNull>
> >                       </dynamic>
> >  </select>
> >
> ></sqlMap>
> >
> >StackTrace:
> >
> >com.ibatis.common.jdbc.exception.NestedSQLException:
> >--- The error occurred while applying a parameter map.
> >--- Check the getQuestion-InlineParameterMap.
> >--- Check the statement (query failed).
> >--- Cause: java.sql.SQLException: ORA-00933: SQL command not properly ended
> >
> >Caused by: java.sql.SQLException: ORA-00933: SQL command not properly ended
> >
> >       at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:181)
> >       at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForObject(GeneralStatement.java:100)
> >       at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:561)
> >       at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:536)
> >       at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:97)
> >       at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForObject(SqlMapClientImpl.java:69)
> >       at
> >
> >Caused by: java.sql.SQLException: ORA-00933: SQL command not properly ended
> >
> >       at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
> >       at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
> >       at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:582)
> >       at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1983)
> >       at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protocol.java:877)
> >       at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2513)
> >       at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2857)
> >       at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:608)
> >       at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:684)
> >       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >       at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> >       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> >       at java.lang.reflect.Method.invoke(Unknown Source)
> >       at com.ibatis.common.jdbc.logging.PreparedStatementLogProxy.invoke(PreparedStatementLogProxy.java:57)
> >       at $Proxy18.execute(Unknown Source)
> >       at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java:180)
> >       at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteQuery(GeneralStatement.java:201)
> >       at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:169)
> >       ... 21 more
> >
> >Caused by:
> >java.sql.SQLException: ORA-00933: SQL command not properly ended
> >
> >       at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
> >       at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
> >       at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:582)
> >       at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1983)
> >       at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protocol.java:877)
> >       at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2513)
> >       at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2857)
> >       at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:608)
> >       at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:684)
> >       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >       at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> >       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> >       at java.lang.reflect.Method.invoke(Unknown Source)
> >       at com.ibatis.common.jdbc.logging.PreparedStatementLogProxy.invoke(PreparedStatementLogProxy.java:57)
> >       at $Proxy18.execute(Unknown Source)
> >       at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java:180)
> >       at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteQuery(GeneralStatement.java:201)
> >       at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:169)
> >       at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForObject(GeneralStatement.java:100)
> >       at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:561)
> >       at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:536)
> >       at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:97)
> >       at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForObject(SqlMapClientImpl.java:69)
> >       at gov.govbenefits.integration.sqlmapdao.TestQuestionSqlMapDao.testGetQuestion(TestQuestionSqlMapDao.java:46)
> >       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >       at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> >       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> >       at java.lang.reflect.Method.invoke(Unknown Source)
> >       at junit.framework.TestCase.runTest(TestCase.java:154)
> >       at junit.framework.TestCase.runBare(TestCase.java:127)
> >       at junit.framework.TestResult$1.protect(TestResult.java:106)
> >       at junit.framework.TestResult.runProtected(TestResult.java:124)
> >       at junit.framework.TestResult.run(TestResult.java:109)
> >       at junit.framework.TestCase.run(TestCase.java:118)
> >       at junit.framework.TestSuite.runTest(TestSuite.java:208)
> >       at junit.framework.TestSuite.run(TestSuite.java:203)
> >       at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:436)
> >       at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:311)
> >       at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
> >
> >
> >
> >
> 
> 
> --
> Kris Jenkins
> Email:  kris@jenkster.com
> Blog:   http://cafe.jenkster.com/
> Wiki:   http://wiki.jenkster.com/
> 
> 
> 
> ___________________________________________________________
> How much free photo storage do you get? Store your holiday
> snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com
> 
> 


-- 
Andrew R. Thompson
Currently in D.C. Consulting

Mime
View raw message