Mybatis查询请求实体未定义默认构造函数引起列映射错误

一、请求
地址:http://localhost:8080/arrival...
信息:
{

"code": "msg.common.fail",
"message": "Error attempting to get column 'LAST_UPDATE_DATE' from result set.  Cause: java.sql.SQLException: 无效的列类型: getInt not implemented for class oracle.jdbc.driver.T4CDateAccessor\n; uncategorized SQLException; SQL state [99999]; error code [17004]; 无效的列类型: getInt not implemented for class oracle.jdbc.driver.T4CDateAccessor; nested exception is java.sql.SQLException: 无效的列类型: getInt not implemented for class oracle.jdbc.driver.T4CDateAccessor",
"success": false

}
返回类定义(注意:此时将Integer routeOrder改为String可正常,但是不符合常理,看报错是LAST_UPDATE_DATE的类型转换错误):

@Data
@Builder
@EqualsAndHashCode(callSuper = true)
@TableName("XXX")
@KeySequence(value = "XXX_S")
@ApiModel(value="XXX", description="XXX")
public class CtnLine extends OracleBaseEntity {

@TableId(value = "ID", type = IdType.INPUT)
private Long id;

@ApiModelProperty(value = "头表ID")
@TableField("HEAD_ID")
private Long headId;

@ApiModelProperty(value = "站点类型代码")
@TableField("ROUTE_LINE_ID")
private Long routeLineId;

@ApiModelProperty(value = "预计到达时间")
@TableField("EST_ARRIVAL_DATE")
private Date estArrivalDate;

@ApiModelProperty(value = "实际到达时间")
@TableField("ACT_ARRIVAL_DATE")
private Date actArrivalDate;

@TableField("CREATOR_NAME")
private String creatorName;

@TableField("CREATOR_NO")
private String creatorNo;

@TableField("UPDATER_NAME")
private String updaterName;

@TableField("UPDATER_NO")
private String updaterNo;

@ApiModelProperty(value = "站点类型描述")
@TableField( exist = false)
private String siteTypeDesc;

@ApiModelProperty(value = "站点名称描述")
@TableField(exist = false)
private String siteNameDesc;

@ApiModelProperty(value = "供应链天数")
@TableField(exist = false)
private Long supplyDays;

@ApiModelProperty(value = "总的路线的排序")
@TableField(exist = false)
private Integer routeOrder;

}

二、经过跟踪及问题排查,是由于返回类实体上面未定义默认构造函数引起
引起的问题
Mybatis查询请求实体未定义默认构造函数引起列映射错误_第1张图片

查看数据库表的字段,刚好第13个字段为出错的Last_UPDATED_DATE字段与实体中的第13个字段routerOrder匹配:
Mybatis查询请求实体未定义默认构造函数引起列映射错误_第2张图片
由于我们框架使用lombok插件,所以只要在实体头上面添加以下两个注记:
@NoArgsConstructor
@AllArgsConstructor

修改后的代码:
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode(callSuper = true)
@TableName("XXX")
@KeySequence(value = "XXX_S")
@ApiModel(value="XXX", description="XXX")
public class CtnLine extends OracleBaseEntity {

@TableId(value = "ID", type = IdType.INPUT)
private Long id;

@ApiModelProperty(value = "头表ID")
@TableField("HEAD_ID")
private Long headId;

@ApiModelProperty(value = "站点类型代码")
@TableField("ROUTE_LINE_ID")
private Long routeLineId;

@ApiModelProperty(value = "预计到达时间")
@TableField("EST_ARRIVAL_DATE")
private Date estArrivalDate;

@ApiModelProperty(value = "实际到达时间")
@TableField("ACT_ARRIVAL_DATE")
private Date actArrivalDate;

@TableField("CREATOR_NAME")
private String creatorName;

@TableField("CREATOR_NO")
private String creatorNo;

@TableField("UPDATER_NAME")
private String updaterName;

@TableField("UPDATER_NO")
private String updaterNo;

@ApiModelProperty(value = "站点类型描述")
@TableField( exist = false)
private String siteTypeDesc;

@ApiModelProperty(value = "站点名称描述")
@TableField(exist = false)
private String siteNameDesc;

@ApiModelProperty(value = "供应链天数")
@TableField(exist = false)
private Long supplyDays;

@ApiModelProperty(value = "总的路线的排序")
@TableField(exist = false)
private Integer routeOrder;

}

你可能感兴趣的:(mybatisjavajson)