mybatis-plus查询报错 Value type "TINYINT" with value "0" cannot be parse as Timestamp;
时间: 2023-12-27 18:02:25 浏览: 29
这个错误通常出现在使用 Mybatis-Plus 进行数据库查询操作时,是因为 Mybatis-Plus 默认会将结果集中的 TINYINT 类型的字段解析为时间戳类型,而 TINYINT 类型的字段不能被解析为时间戳。
解决这个问题的方法是,在对应的实体类中,将 TINYINT 类型的字段使用 @TableField 注解进行标注,指定其对应的数据库列名和数据库类型。例如:
```
public class User {
@TableId
private Long id;
@TableField(value = "name")
private String name;
@TableField(value = "age")
private Integer age;
@TableField(value = "is_deleted", jdbcType = JdbcType.TINYINT)
private Integer isDeleted;
// ...
}
```
在这个例子中,isDeleted 字段被标注为 TINYINT 类型,同时使用 jdbcType 属性指定其对应的数据库列的类型为 TINYINT。
另外,如果查询语句中涉及到时间戳类型的字段,也需要使用 @TableField 注解进行标注,并指定其对应的数据库列名和数据库类型。例如:
```
public class Order {
@TableId
private Long id;
@TableField(value = "order_no")
private String orderNo;
@TableField(value = "create_time", jdbcType = JdbcType.TIMESTAMP)
private Date createTime;
// ...
}
```
在这个例子中,createTime 字段被标注为时间戳类型,同时使用 jdbcType 属性指定其对应的数据库列的类型为 TIMESTAMP。