ibatis的所有配置文件应该正确,没有报错,所有语句调用也经过了测试类测试通过,但是启动Tomcat从页面调用action对数据库写数据的时候出现了这个问题:
com.ibatis.sqlmap.client.SqlMapException: There is no statement named insertGroup in this SqlMap.
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.getMappedStatement(SqlMapExecutorDelegate.java:293)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.insert(SqlMapExecutorDelegate.java:429)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.insert(SqlMapSessionImpl.java:82)
at org.springframework.orm.ibatis.SqlMapClientTemplate$9.doInSqlMapClient(SqlMapClientTemplate.java:369)
at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:193)
at org.springframework.orm.ibatis.SqlMapClientTemplate.insert(SqlMapClientTemplate.java:367)
.......
我可以肯定问题不是处在action
写数据库的impl调用如下(通过编写测试类测试通过):
public void insertGroup(Book_GROUP group) {
try{
getSqlMapClientTemplate().insert("insertGroup",group);
System.out.println("Insert Success...");
}catch(Exception e){
e.printStackTrace();
}
}
而数据库映射文件如下:
<!---->
<sqlmap namespace="BookOperation">
<typealias alias="group" type="com.talkweb.companyfax.bean.Book_GROUP">
<typealias alias="user" type="com.talkweb.companyfax.bean.Book_USER">
<!---->
<!---->
<insert id="insertGroup" parameterclass="group">
<!---->
</insert>
</sqlmap>
为什么找不到insertGroup呢?百度了很久都没有找到答案,希望各位指点指点啊。。。
问题补充测试类代码
package com.talkweb.companyfax.book;
import java.lang.String;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.talkweb.companyfax.bean.Book_GROUP;
import com.talkweb.companyfax.impl.Book_groupDAOimpl;
public class Main {
//test
public static ApplicationContext context=new ClassPathXmlApplicationContext("com/talkweb/companyfax/book/applicationContext-fax-book.xml");
public static Book_groupDAOimpl groupdaoimpl=(Book_groupDAOimpl)context.getBean("groupdaoimpl");
public static void main(String[] args){
Book_GROUP group=new Book_GROUP();
group.setGroup_id("43");
group.setUser_id("1");
group.setGroup_name("test_insert");
group.setGroup_des("test_insert");
try{
insertGroup(group);
}catch(Exception e){
System.out.println(e.getMessage());
}
}
public static void insertGroup(Book_GROUP group){
//插入数据
groupdaoimpl.insertGroup(group);
System.out.println(
"成功插入数据..."+"\n"
+"group_id="+group.getGroup_id()+"\n"
+"user_id="+group.getUser_id()+"\n"
+"group_name="+group.getGroup_name()+"\n"
+"group_des="+group.getGroup_des()
);
}
}
运行结果:
log4j:WARN No appenders could be found for logger (org.springframework.context.support.ClassPathXmlApplicationContext).
log4j:WARN Please initialize the log4j system properly.
成功插入数据...
group_id=43
user_id=1
group_name=test_insert
group_des=test_insert
问题补充抛出异常的爱 写道
有可能是:
一个是在<sqlmapconfig>有没有注册
一个是getSqlMapClientTemplate().insert("BookOperation.insertGroup",group);
<sqlmapconfig>注册过了
我没有设置useStatementNamespaces,应该不用通过BookOperation.insertGroup这样调用
这个是在测试类里面测试成功的。。。
为什么在action里面不成功感觉就很诡异了。。。
相关推荐
之前一直找原因,最后知道了解决方法,具体请下载源码查看。特别是用到throw的事务中
12. "There is no doubt that children can get more learning resources on the Net compared to a traditional classroom." 这个句子使用了 "there is no doubt that" 的结构,强调网络学习资源的丰富性是毋庸置疑...
I never thought there would be so many people. Lu Yi: Same here. By the way, my name is Lu Yi. Dick: Glad to meet you, Mr Lu. I'm Richard Green. Lu Yi: I beg your pardon. I didn't catch your first ...
There is also a GitBook version of the book: http://waylau.gitbooks.io/spring-framework-4-reference. Let's READ! 《Spring Framework 4.x参考文档》中文翻译(包含了官方文档以及其他文章)。至今为止,...
eclipse中使用xml自动提示功能所需文件:mybatis-3-mapper.dtd eclipse中使用xml自动提示功能所需文件:mybatis-3-mapper.dtd eclipse中使用xml自动提示功能所需文件:mybatis-3-mapper.dtd
一般疑问句:Is there a bird in the tree? 肯定回答:Yes, there is. 否定回答:No, there isn’t. 8. 原句:There are many stars in the sky. 一般疑问句:Are there many stars in the sky? 肯定回答:Yes...
JS错误Uncaught SyntaxError: Cannot use import statement outside a module< 分析及解决方法 错误信息: 错误分析: HTML 网页中,浏览器通过 script 标签加载 JavaScript 脚本。由于浏览器脚本的默认语言是 ...
- 一般疑问句:Is there a bird in the tree? - 肯定回答:Yes, there is. - 否定回答:No, there isn’t. 8. - 原句:There are many stars in the sky. - 一般疑问句:Are there many stars in the sky? - ...
- "毋庸置疑":There is no denying that..., - "毫无疑问":There is no doubt that..., - "不可否认":It cannot be denied that..., 4. **论证观点的结构**: - "一方面...另一方面...":For one thing..., ...
改为:Is it a bed? 肯定回答:Yes, it is. 2. This is a kite. 改为:Is this a kite? 肯定回答:Yes, it is. 3. That is a fat sheep. 改为:Is that a fat sheep? 肯定回答:Yes, it is. 4. She is a good girl....
...本文将详细介绍该错误产生的原因、解决方法,并通过具体的示例来帮助读者理解如何避免此类错误。 #### 错误描述 根据提供的内容描述,出现的错误为`MWMCR::EvaluateFunction error: Undefined function or method...
10. 信心鼓励句型:There is no doubt that... 给予读者信心,如遇到困难时总会得到帮助。 11. 可能性推测句型:It seems certain that... 表达对某种可能性的肯定,如他们已经进行了一系列实验。 12. 历史事实...
例如:There is no denying that diligence is indispensable for academic success. 3. **表达“我深信”的句型**: - I am greatly convinced that... - I am greatly assured that... 例如:I am greatly ...
11. 强调事实不容忽视:There's no denying the fact that... 12. 强调重要性:Nothing is more important than the fact that... 13. 引导进一步阐述:What's far more important is that... 二、衔接句型 这些...
Create a hover view, there is no rules to obey. Just please remember that this view will be stretched as large as the original view you have created. Bind a hover view to BlurLayout BlurLayout ...
7. **next to**:表示紧邻:There is a bus station next to No. 13 Middle School. 8. **over**:表示正上方:A bridge is over the river. 9. **on the left**:表示在左边:The bookstore is on the left. 10....
一般疑问句:Is there a book on the desk? 回答:Yes, there is./No, there isn't. 7. 原句:There are some dictionaries on the floor. 一般疑问句:Are there any dictionaries on the floor? 回答:Yes, ...
g_message := 'There is still an amount in stock.'; ... END; ``` 7. **异常处理指导原则**: - `WHEN OTHERS THEN`子句应作为最后的处理选项,用来捕获所有未明确定义的异常。 - 异常处理部分应该包含适当...
使用python直接使用pip install xx时,出现 Could not fetch URL https://pypi.python.org/simple/requests/: There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate ...
Turning an iPhone on and off should be easy— and it is. However, the iPhone can be in one of four states: on, off, sleep, or airplane mode. If all of this sounds more confusing than just turn- ing ...