sql语句可以查出来,但是mybatis查不出来,用的是orcale数据库

XML中内容:

 <sql id="subscriptionColumn">
        sub.id "sub.id",
        sub.no "sub.no",
        sub.linkman "sub.linkman",
        sub.phone "sub.phone",
        sub.email "sub.email",
        sub.status "sub.status"
    </sql>

<resultMap type="entity.SubScription" id="subScriptionResultMapper">
        <id property="id" column="sub.id"/>
        <result property="no" column="sub.no"/>
        <result property="linkman" column="sub.linkman"/>
        <result property="phone" column="sub.phone"/>
        <result property="email" column="sub.email"/>
        <result property="status" column="sub.status"/>
</resultMap>

<select id="selectBySubScriptions" parameterType="vo.SubScriptions" resultMap="subScriptionResultMapper">
        select <include refid="subscriptionColumn"></include>
        from category c,
        subscription sub,
        subscription_dtl dtl,
        room r,
        member m
        where m.id=sub.mid
        and sub.mid=dtl.sid
        and r.id=dtl.rid
        and r.cid=c.id
            <if test="categroyId!=null">and c.id=#{categroyId}</if>
            <if test="status!=null">and sub.status=#{status}</if>
            <if test="no!=null">and sub.no=#{no}</if>
            <if test="memberName!=null">and m.username=#{memberName}</if>
            <if test="sdate!=null">and dtl.sdate&gt;#{sdate}</if>
            <if test="edate!=null">and dtl.edate&lt;#{edate}</if>
</select>

接口dao

public interface SubScriptionDao {
    public List<SubScription> selectBySubScriptions(SubScriptions subScriptions);
}

自己写的测试类,用工厂创建实例对象

 public class text {
    public static void main(String[] args) {
        SubScriptionDao subScriptionDao=(SubScriptionDao) ObjectFactory.getObject("subScriptionDao");
        SubScriptions ss=new SubScriptions();
        List<SubScription> s = subScriptionDao.selectBySubScriptions(ss);
        System.out.println("list:"+s);
    }
}

控制台也没报错,使用下面Log4J中的sql语句可以在数据库中查到数据:

 DEBUG ooo Using Connection [oracle.jdbc.driver.T4CConnection@15e2075]
DEBUG ==>  Preparing: select sub.id "sub.id", sub.no "sub.no", sub.linkman "sub.linkman", sub.phone "sub.phone", sub.email "sub.email", sub.status "sub.status" from category c, subscription sub, subscription_dtl dtl, room r, member m where m.id=sub.mid and sub.mid=dtl.sid and r.id=dtl.rid and r.cid=c.id 
DEBUG ==> Parameters: 
List[]

数据库中内容:
1 1478199128994 fsa sfadfs dfsfsad 未生效
2 1478200504349 熊峰 3412 421412 未生效

1个回答

这种情况是参数的错误

qq_21976567
JavaEE小能手 我也遇到了这个问题,我用逆向工具生成的,在PLSQL里面运行日志打印的sql语句可以查出来,同一个类型的条件换一个也能查
2 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐