Mybatis查询返回对象为null

Mapper.xml中映射sql如下,查询返回对象Production 为null。

 <select id="selectOneByTime" resultType="model.Production">
    select *
    from CNC_Production
    where dataTime &lt; #{date}
    limit 1
  </select>

Mysql中对应表明为 XXX_Production。
表名与其生成的model名不同,resultType需要完全相同才能对应。
需要在mapper.xml文件中增加resultMap的声明。

 <resultMap id="ResultMap" type="model.Production" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="machineID" property="machineid" jdbcType="INTEGER" />
    <result column="yield" property="yield" jdbcType="INTEGER" />
    <result column="programCode" property="programcode" jdbcType="VARCHAR" />
    <result column="StartTime" property="starttime" jdbcType="TIMESTAMP" />
    <result column="EndTime" property="endtime" jdbcType="TIMESTAMP" />
    <result column="dataTime" property="datatime" jdbcType="TIMESTAMP" />
    <result column="status" property="status" jdbcType="INTEGER" />
    <result column="UpdateTime" property="updatetime" jdbcType="TIMESTAMP" />
  </resultMap>
  <select id="selectOneByTime" resultMap="ResultMap">
    select *
    from CNC_Production
    where dataTime &lt; #{date}
    limit 1
  </select>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值