定义了两个表,然后两个表有个相同名字的查询方法在表A中的xml文件中写了这个方法
表B中的xml文件中忘记写这个方法了结果,在调用表B的那条查询语句的时候,莫名奇妙的居然查到表A中了然后再表B的xml文件中加上这个方法,就没问题了
之后反复测试了下,发现这个问题一直存在,表B中的查询语句怎么查到表A中了~~~
表B中的xml文件中忘记写这个方法了结果,在调用表B的那条查询语句的时候,莫名奇妙的居然查到表A中了然后再表B的xml文件中加上这个方法,就没问题了
之后反复测试了下,发现这个问题一直存在,表B中的查询语句怎么查到表A中了~~~
解决方案 »
- Struts提交表单后报IndexOutOfBoundsException错误
- CSDN无人???sql 存取ntext大字段操作?没人会解决?
- 谁知道tomcat status里面的error count是什么意思?
- 请问JBPM部署在tomcat6中报错:Not supported by BasicDataSour
- 你们做菜单时会经常用到Struts-menu吗?
- 用Java Service获取XML文件数据
- myeclipse中启动jboss错误!
- 怎么在tomcat中加入我自己写的mbean?(300分)
- cmp-field and a cmr-field(Morgan_ma来接分)
- Failed to execute goal com.spotify:docker-maven-plugin:1.2.0:build (build-image)
- 支付宝支付接口集成
- 请java高手们进来帮帮忙!!!!!!
这个是一个表的查询语句 <select id="selectByAuid" parameterType="string" resultType="model.SnsInfo">
select * from sns_info where auid=#{auid}
</select>
这个是另一个表查询语句<select id="selectByAuid" parameterType="string" resultType="model.UserInfo">
select * from user_info where auid=#{auid}
</select>
之前是其中一个没写这句select,结果就查到另一个表里了
当然了,之后的类转换的时候出问题了,但是郁闷的是为什么能查出东西,
按说这两个在不同的配置文件里啊
public class IUserInfoDAOImpl extends SqlSessionDaoSupport implements
IUserInfoDAO {
private UserInfoMapper mapper = getSqlSessionTemplate().getMapper(
UserInfoMapper.class); public void update(UserInfo info) {
mapper.update(info);
} public void insert(UserInfo info) {
mapper.insert(info);
}
...
<mapper namespace="flipboard.mapper.UserInfoMapper">
<resultMap id="baseResultMap" type="flipboard.model.UserInfo">
<result column="id" property="id" jdbcType="INTEGER" />
<result column="auid" property="auid" jdbcType="VARCHAR" />
...
<select ...>
sqlMapConfig
<mapper resource="sqlMap/UserInfoMapper.xml" />
<mapper resource="sqlMap/SnsInfoMapper.xml" />
<sqlMapConfig>
<settings
useStatementNamespaces ="true"
/>
<sqlMap resource="com/edwin/db/config/Module.xml"/>
</sqlMapConfig>
<mappers>
<mapper resource="sqlMap/UserInfoMapper.xml" />
<mapper resource="sqlMap/SnsInfoMapper.xml" />
<select id="selectBlog" parameterType="int" resultType="Blog">
select * from Blog where id = #{id}
</select>
</mapper>
调用的时候:
Blog blog = (Blog) session.selectOne(
"org.mybatis.example.BlogMapper.selectBlog", 101);org.mybatis.example.BlogMapper.selectBlog=命名空间+id以上来自官方素材。
id 一致了, 除非namespace不一样!
<mapper namespace="flipboard.mapper.UserInfoMapper"> private UserInfoMapper mapper = getSqlSessionTemplate().getMapper(
UserInfoMapper.class);我想的是用上面的方法得到userinfomapper对应的namespace所在的mapper
那这样的mapper的select语句为什么会去别的namespace下找
即使id是一样的,但这个mapper是属于哪个namespace的这个应该是确定的
只用过2.3,看你的配置像是3.x的。不过2.3里面默认不适用namespace,不知3.x是不是