为了账号安全,请及时绑定邮箱和手机立即绑定

为什在测试successSeckill的时候查出来的是null,前面测试insert已经成功数据库也有相应的字段

测试类-----------------------

@Test

public void testInsertSuccessKilled() {

long userPhone = 13550922395L;

long seckillId = 9998L;

int count =  successKillDao.insertSuccessKilled(seckillId, userPhone);

System.out.println("count = " + count);

}


@Test

public void testQueryByIdWithSecKill() {

long userPhone = 13550922395L;

long seckillId = 9998L;

SuccessKilled successSeckill = successKillDao.queryByIdWithSecKill(seckillId, userPhone);

System.out.println(successSeckill);

}

----------------------------控制台输出

13:21:49.178 [main] DEBUG o.m.s.t.SpringManagedTransaction - JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@19932c16] will not be managed by Spring

13:21:49.265 [main] DEBUG c.s.d.S.queryByIdWithSecKill - ==>  Preparing: select sk.seckill_id, sk.user_phone, sk.create_time, s.seckill_id "seckill.seckill_id", s.name "seckill.name", s.number "seckill.number", s.start_time "seckill.start_time", s.end_time "seckill.end_time", s.create_time "seckill.create_time" from success_killed sk inner join seckill s on sk.seckill_id = s.seckill_id where sk.seckill_id=? and sk.user_phone = ? 

13:21:49.457 [main] DEBUG c.s.d.S.queryByIdWithSecKill - ==> Parameters: 9998(Long), 13550922395(Long)

13:21:49.601 [main] DEBUG c.s.d.S.queryByIdWithSecKill - <==      Total: 0

13:21:49.616 [main] DEBUG org.mybatis.spring.SqlSessionUtils - Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@53fb3dab]

null

-----------------------------sql

<select id="queryByIdWithSecKill" resultType="SuccessKilled">

<!-- 根据查询successKilled同时并携带seckill实体 -->

<!-- 如果告诉mybatis把结果集映射到seccessKilled同时映射到seckill属性 -->

<!-- 可以自由控制SQL -->

select 

sk.seckill_id,

sk.user_phone,

sk.create_time,

s.seckill_id "seckill.seckill_id",

s.name "seckill.name",

s.number "seckill.number",

s.start_time "seckill.start_time",

s.end_time "seckill.end_time",

s.create_time "seckill.create_time"

from success_killed sk

inner join seckill s on sk.seckill_id = s.seckill_id

where sk.seckill_id=#{seckillId} and sk.user_phone = #{userPhone}

</select>

------------------求解啊

正在回答

1 回答

因为在seckill里面的seckillId没有9998

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

为什在测试successSeckill的时候查出来的是null,前面测试insert已经成功数据库也有相应的字段

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信