用mybatis查询之后传到前端的参数有缺失
entity属性
public class OnPassageInfoEntity {
// 在途信息ID,注释均为问题字段
Long onPassageId;
// 单据ID
Long billId;
String message;
String time;
String driver;
// 联系方式
String phoneNumber;
int status;
String createBy;
String createTime;
String updateBy;
String updateTime;
String fields;
}
service
List<OnPassageInfoEntity> entityList = onPassageDao.listOnPassageInfoByBillId(billId);
mybatis配置文件
<select id="listOnPassageInfoByBillId" resultType="com.boss.eship.billing.server.entity.OnPassageInfoEntity">
select id,billing_info_id,message,time,driver,contact_information,status,create_by,create_time,update_by,update_time,fields from `business_on_passage_info` where billing_info_id = #{billId}
</select>
数据库
debug结果
控制台数据库查询结果正常
debug结果数字信息为null
参考此链接,数据库表的字段和java的实体类字段对不上,建议配置ResultMap,查询返回的时候,用resultMap而不用resultType
修改后的mybatis
<resultMap id="OnPassageInfoMap" type="com.boss.eship.billing.server.entity.OnPassageInfoEntity">
<id column="id" jdbcType="BIGINT" property="onPassageId" />
<result column="billing_info_id" jdbcType="BIGINT" property="billId"/>
<result column="message" jdbcType="VARCHAR" property="message" />
<result column="time" jdbcType="TIMESTAMP" property="time" />
<result column="driver" jdbcType="VARCHAR" property="driver" />
<result column="contact_information" jdbcType="VARCHAR" property="phoneNumber" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="createBy" jdbcType="VARCHAR" property="createBy" />
<result column="createTime" jdbcType="TIMESTAMP" property="createTime" />
<result column="updateBy" jdbcType="VARCHAR" property="updateBy" />
<result column="updateTime" jdbcType="TIMESTAMP" property="updateTime" />
<result column="fields" jdbcType="VARCHAR" property="fields" />
</resultMap>
<select id="listOnPassageInfoByBillId" resultMap="OnPassageInfoMap">
select id,billing_info_id,message,time,driver,contact_information,status,create_by,create_time,update_by,update_time,fields from `business_on_passage_info` where billing_info_id = #{billId}
</select>
问题解决
注:
数据库类型和Java类型对应参考