这是我的 BaseEntity
package com.txys.system.entity; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.extension.activerecord.Model; import lombok.Data; @Data public abstract class BaseEntity<T> extends Model<BaseEntity<T>> { @TableField(value = "createdBy") private String createdBy; @TableField(value = "createdAt") private String createdAt; @TableField(value = "updatedAt") private String updatedAt; @TableField(value = "updatedBy") private String updatedBy; @TableField(value = "deletedAt") private String deletedAt; } 这是我的 SystemUser 表
package com.txys.system.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import java.io.Serializable; @TableName("\"SystemUser\"") @Data public class SystemUser extends BaseEntity<SystemUser> implements Serializable { @TablId(value = "id", type = IdType.AUTO) private Integer id; @TableField(value = "username") private String username; @TableField(value = "password") private String password; } ###1 、我现在的问题是:继承了 BaseEntity 父类,调用 selectById ,
SELECT id,username,password,createdBy,createdAt,updatedAt,updatedBy,deletedAt FROM "SystemUser" WHERE id=? 查询时会自动加上父类继承的字段,如果父类字段加上 exsit=false ,那么查询就也不会带上父类字段,但以前使用 MySQL 的时候是可以被识别的。
查询结果映射的时候,会报错:
Error querying database. Cause: org.postgresql.util.PSQLException: 错误: 字段 "createdby" 不存在
也就是说:映射找不到继承的父类公共字段
问过 mybatis-plus 官方,他们说是 postgresql 驱动那边的异常,但没具体告诉我该怎么去排查解决,网上也没搜到这种类似的问题。
