我正在使用 Ibator 生成 Ibatis 的东西,所以所有的工件都是自动生成的。我正在尝试做一个简单的插入,虽然表存在,但给出异常“未找到表”,我可以从控制台查询它。
这是错误
org.springframework.jdbc.BadSqlGrammarException: SqlMapClient operation; bad SQL grammar []; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:
--- 错误发生在 com/sqlmaps/MY_TABLE_NAME_SqlMap.xml。
--- 应用参数映射时发生错误。
--- 检查##MY_TABLE_NAME.insert-InlineParameterMap。
--- 检查语句(更新失败)。
--- 原因:java.sql.SQLException:SQL Anywhere 错误 -141:未找到表 '#MY_TABLE_NAME'
SQL 映射文件
<?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>
在 Ibator 配置中,我定义了表属性
<property name="runtimeTableName" value="##MY_TABLE_NAME" />