问答详情
源自:4-8 DAO层单元测试编码和问题排查(上)

就差最后一个了,怎么实现不了,求助

搞一晚上也没搞明白错在哪

04:41:26.386 [main] DEBUG org.seckill.dao.SuccessKilledDao.query - ==>  Preparing: SELECT SK.id, SK.tel, SK.create_time, SK.state, S.id "seckill.id", S.name "seckill.name", S.num "seckill.num", 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.ID = S.ID WHERE SK.ID = ? AND SK.TEL=?
04:41:26.502 [main] DEBUG org.seckill.dao.SuccessKilledDao.query - ==> Parameters: 1003(Integer), 123456(Integer)

Caused by: org.apache.ibatis.executor.ExecutorException: No constructor found in org.seckill.entity.SuccessKilled matching [java.math.BigDecimal, java.math.BigDecimal, oracle.sql.TIMESTAMP, java.math.BigDecimal, java.math.BigDecimal, java.lang.String, java.math.BigDecimal, oracle.sql.TIMESTAMP, oracle.sql.TIMESTAMP, oracle.sql.TI


这是配置

<select id="query" resultType="SuccessKilled">
   SELECT
       SK.id,
       SK.tel,
       SK.create_time,
       SK.state,
       S.id          "seckill.id",
       S.name        "seckill.name",
       S.num         "seckill.num",
       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.ID = S.ID
   WHERE SK.ID = #{id} AND SK.TEL=#{tel}
</select>MESTAMP]

调用@Test
public void query() throws Exception {
   SuccessKilled successKilled=successKilledDao.query(1003,123456);
   System.out.println(successKilled);
}

两个实体类

package org.seckill.entity;

import oracle.sql.TIMESTAMP;

import java.math.BigDecimal;


public class SuccessKilled {
   private BigDecimal id;
   private BigDecimal tel;
   private BigDecimal state;
   private TIMESTAMP createTime;
   private Seckill seckill;

   public SuccessKilled(BigDecimal id, BigDecimal tel, BigDecimal state, TIMESTAMP createTime, Seckill seckill) {
       this.id = id;
       this.tel = tel;
       this.state = state;
       this.createTime = createTime;
       this.seckill = seckill;
   }

   public BigDecimal getId() {
       return id;
   }

   public void setId(BigDecimal id) {
       this.id = id;
   }

   public BigDecimal getTel() {
       return tel;
   }

   public void setTel(BigDecimal tel) {
       this.tel = tel;
   }

   public BigDecimal getState() {
       return state;
   }

   public void setState(BigDecimal state) {
       this.state = state;
   }

   public TIMESTAMP getCreateTime() {
       return createTime;
   }

   public void setCreateTime(TIMESTAMP createTime) {
       this.createTime = createTime;
   }

   public Seckill getSeckill() {
       return seckill;
   }

   public void setSeckill(Seckill seckill) {
       this.seckill = seckill;
   }

   @Override
   public String toString() {
       return "successKilled{" +
               "id=" + id +
               ", tel=" + tel +
               ", state=" + state +
               ", createTime=" + createTime +
               '}';
   }
}



package org.seckill.entity;

import oracle.sql.TIMESTAMP;

import java.math.BigDecimal;


public class Seckill {
   private BigDecimal id;
   private String name;
   private BigDecimal num;
   private TIMESTAMP startTime;
   private TIMESTAMP endTime;
   private TIMESTAMP createTime;

   public Seckill(BigDecimal id, String name, BigDecimal num, TIMESTAMP startTime, TIMESTAMP endTime, TIMESTAMP createTime) {
       this.id = id;
       this.name = name;
       this.num = num;
       this.startTime = startTime;
       this.endTime = endTime;
       this.createTime = createTime;
   }

   public Seckill() {
   }

   public BigDecimal getId() {
       return id;
   }

   public void setId(BigDecimal id) {
       this.id = id;
   }

   public String getName() {
       return name;
   }

   public void setName(String name) {
       this.name = name;
   }

   public BigDecimal getNum() {
       return num;
   }

   public void setNum(BigDecimal num) {
       this.num = num;
   }

   public TIMESTAMP getStartTime() {
       return startTime;
   }

   public void setStartTime(TIMESTAMP startTime) {
       this.startTime = startTime;
   }

   public TIMESTAMP getEndTime() {
       return endTime;
   }

   public void setEndTime(TIMESTAMP endTime) {
       this.endTime = endTime;
   }

   public TIMESTAMP getCreateTime() {
       return createTime;
   }

   public void setCreateTime(TIMESTAMP createTime) {
       this.createTime = createTime;
   }

   @Override
   public String toString() {
       return "Seckill{" +
               "id=" + id +
               ", name='" + name + '\'' +
               ", num=" + num +
               ", startTime=" + startTime +
               ", endTime=" + endTime +
               ", createTime=" + createTime +
               '}';
   }
}

提问者:世界知名伟人 2017-04-09 04:48

个回答

  • 世界知名伟人
    2017-04-09 18:08:43

    已解决,缺少无参构造函数