定义了两个表,然后两个表有个相同名字的查询方法在表A中的xml文件中写了这个方法
表B中的xml文件中忘记写这个方法了结果,在调用表B的那条查询语句的时候,莫名奇妙的居然查到表A中了然后再表B的xml文件中加上这个方法,就没问题了
之后反复测试了下,发现这个问题一直存在,表B中的查询语句怎么查到表A中了~~~

解决方案 »

  1.   

    把xml都贴出来,不然神都不知道你哪错了
      

  2.   

    说的很对~~    
    这个是一个表的查询语句 <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,结果就查到另一个表里了
    当然了,之后的类转换的时候出问题了,但是郁闷的是为什么能查出东西,
    按说这两个在不同的配置文件里啊
      

  3.   


    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);
    }
    ...
      

  4.   

    你没定义namespace吗?应该用namespace名称.sqlID就可以了。
      

  5.   

    为了放转id重复,最好定义namespace,这样就不会出现LZ那样的情况了
      

  6.   

    肯定定义了啊
    <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" />
      

  7.   

    配置文件
    <sqlMapConfig>
       <settings       
          useStatementNamespaces ="true"
       />
       <sqlMap resource="com/edwin/db/config/Module.xml"/>
    </sqlMapConfig>
      

  8.   

    请问,使用下面这种方式该怎么配置啊<configuration>
    <mappers>
    <mapper resource="sqlMap/UserInfoMapper.xml" />
    <mapper resource="sqlMap/SnsInfoMapper.xml" />

      

  9.   

    我那版本比你的低,但是你要明白使用命名空间来解决冲突。<mapper namespace="org.mybatis.example.BlogMapper">
    <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以上来自官方素材。
      

  10.   

    <select id="selectByAuid" 
    id 一致了, 除非namespace不一样!
      

  11.   

    namespace不一样啊<mapper namespace="flipboard.mapper.SnsInfoMapper">
    <mapper namespace="flipboard.mapper.UserInfoMapper"> private UserInfoMapper mapper = getSqlSessionTemplate().getMapper(
                UserInfoMapper.class);我想的是用上面的方法得到userinfomapper对应的namespace所在的mapper
    那这样的mapper的select语句为什么会去别的namespace下找
    即使id是一样的,但这个mapper是属于哪个namespace的这个应该是确定的
      

  12.   


    只用过2.3,看你的配置像是3.x的。不过2.3里面默认不适用namespace,不知3.x是不是
      

  13.   

    能否把sqlMapClient.queryForObject()贴出了看看。继续分析。一定是哪里弄错了。
      

  14.   

    用的是mybaits 3.0.1sqlMapClient 没用到这个