简体   繁体   中英

SqlMapClient operation; bad SQL grammar : Table not found

I am using Ibator to generate Ibatis stuffs so all the artifacts are auto generated. I am trying to do a simple insert which is giving exception "table not found" though table is existing" and I can query it from console.

Here is the error

org.springframework.jdbc.BadSqlGrammarException: SqlMapClient operation; bad SQL grammar []; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:   

--- The error occurred in com/sqlmaps/MY_TABLE_NAME_SqlMap.xml.
--- The error occurred while applying a parameter map.
--- Check the ##MY_TABLE_NAME.insert-InlineParameterMap.
--- Check the statement (update failed).
--- Cause: java.sql.SQLException: SQL Anywhere Error -141: Table '#MY_TABLE_NAME' not found

SQL MAP file

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="##MY_TABLE_NAME">
  <insert id="insert" parameterClass="com.model.MyTable">
    <!--
      WARNING - @ibatorgenerated
      This element is automatically generated by Apache iBATIS Ibator, do not modify.
      This element was generated on Mon Jul 06 19:54:34 IST 2015.
    -->
    insert into ##MY_TABLE_NAME (field1, field2, field3, field4)
    values (#field1:tinyint#, #field2:DATE#, #field3:INT#, #field4:BIGINT#)
  </insert>
 </sqlMap>

Inside the Ibator config I have defined table property

<property name="runtimeTableName" value="##MY_TABLE_NAME" />

I added below code to log4j.xml to check what query it is generating

<logger name="java.sql" additivity="false">
<level value="debug" />
<appender-ref ref="CONSOLE" />

and I found that it was generating wrong table name, it was prefixing table name with #symbol, which was wrong in ibatorConfig.xml

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM