iBatis的AutoResultMap 默认配置使用时候出现的问题
来源:互联网 发布:4级英语词汇软件 编辑:程序博客网 时间:2024/05/18 12:30
<script type="text/javascript">google_ad_client = "pub-5033576919944123";google_ad_width = 728;google_ad_height = 90;google_ad_format = "728x90_as";google_ad_type = "text_image";//2007-10-24: csdn.bloggoogle_ad_channel = "8548491739";</script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
iBatis的AutoResultMap 默认配置使用时候出现的问题
演示的sqlMap 配置文件,通过'$'和'*'的使用,达到动态映射Table到一个map的作用
<? xml version="1.0" encoding="UTF-8" ?>
<! DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd" >
< select id ="useAutoResultMapExample" parameterClass ="map" >
USE $dbName$
SELECT* FROM $tableName$
</ select >
</ sqlMap >
<! DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd" >
< select id ="useAutoResultMapExample" parameterClass ="map" >
USE $dbName$
SELECT* FROM $tableName$
</ select >
</ sqlMap >
也就是在IBatis里面配置一个statment,去执行多个查询,充分利用了map映射的特性.
去执行多个查询。
比如
select * from myexample
select * from mywork
使用"*" 而且没有用resultClass 指定返回
但是在默认配置下,在使用的时候的时候
2次以上传入不同的$dbName$,$tabeName$ 调用这个useAutoResultMapExample,
就要报java.sql.SQLException: Invalid column name错误
因为iBatis自己有 AutoResultMap的cache,尽管你传入的$tableName$不同,但是他总是
用第一个建立的AutoResultMap的cache去匹配以后的$tableName$当然有错误了
解决方法: 使用多个statment或者使用 remapResults="true" (为了效率他默认的是false)
以上由于效率问题,建议还是采用多个statement 映射到不同的model上面去,不建议生产系统也这么使用。
<script type="text/javascript">google_ad_client = "pub-5033576919944123";google_ad_width = 728;google_ad_height = 90;google_ad_format = "728x90_as";google_ad_type = "text_image";//2007-10-24: csdn.bloggoogle_ad_channel = "8548491739";</script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
- iBatis的AutoResultMap 默认配置使用时候出现的问题
- iBatis的AutoResultMap 默认配置使用时候出现的问题
- ibatis出现AutoResultMap错误的问题
- 关于ibatis出现AutoResultMap错误的问题
- 关于ibatis出现AutoResultMap错误的问题
- AutoResultMap的问题
- ibatis使用存储过程的时候发现了点问题
- 使用NetBean编程时候出现的问题
- RecyclerView 使用headView的时候出现问题
- Ibatis常出现的问题
- spring,ibatis集成的时候碰到问题
- 使用不同的配置,利用Zend Framework时候,出现的问题
- 使用Ibatis,出现的错误
- maven 配置 struts2 hibernate3 spring2 的时候出现的问题
- 配置spring文件时候出现的小问题
- makefile出现问题的时候
- 使用注解@Resoure的时候容易出现的问题
- 关于saveFileDialog使用的时候出现的问题
- Java 的反射机制
- Hibernate3集合映射中排序功能的一些不足?
- CHAR与TCHAR处理函数
- 信息安全遐思
- jsf自定义组件-jafyear选择年份
- iBatis的AutoResultMap 默认配置使用时候出现的问题
- C++程序设计之四书五经
- 黑客六次网络大战
- 关于IE、Firefox、Opera页面呈现异同
- C语言实现CRC算法实例改进
- 查看MySQL的table信息
- .net C# 跨越线程调用窗体上的控件一个完整的例子
- 针对equalizer(v0.3)中eqPly的分析
- 浅谈C++程序员的学习