qq_Ve_14
2016-12-07 13:29
测试类-----------------------
@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>
------------------求解啊
因为在seckill里面的seckillId没有9998
Java高并发秒杀API之业务分析与DAO层
87426 学习 · 496 问题
相似问题