这篇“mybatisplus+pgsql查询bug怎么解决”文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇“mybatisplus+pgsql查询bug怎么解决”文章吧。
这是sys_user表,我要根据id查这两条数据,一个id为3,一个id为5
这是4条查询语句,前2条根据id为3的查,后两条根据id为5的查
以下是根据id为3来查,
数据正常查了处理,departmentId也不为空,为啥这里我要提到 departmentId这段,请接着看,
奇怪的事情发生了,当id为5的查询时,数据也查出来了,确实是数据库里的那两条数据,但是
departmentId居然为null,这就很离谱
这是实体:
package com.xmirror.entity.entity.system; import com.baomidou.mybatisplus.annotation.TableField;import com.baomidou.mybatisplus.annotation.TableName;import com.fasterxml.jackson.annotation.JsonFormat;import com.fasterxml.jackson.annotation.JsonInclude;import com.xmirror.entity.base.BaseEntity;import lombok.Data;import lombok.EqualsAndHashCode;import lombok.ToString;import org.springframework.format.annotation.DateTimeFormat;import org.springframework.security.core.GrantedAuthority;import org.springframework.security.core.authority.SimpleGrantedAuthority;import org.springframework.security.core.userdetails.UserDetails; import java.beans.Transient;import java.util.*; @Data@TableName("sys_user")@ToString(callSuper = true)@EqualsAndHashCode(callSuper = true)@JsonInclude(JsonInclude.Include.NON_NULL)public class User extends BaseEntity implements UserDetails { private String username; private String password; private String realName; private String phone; private String email; private Integer status; private Integer departmentId; @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date authStartTime; @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date authEndTime; private Integer loginFailCount; @TableField(exist = false) private Integer roleId; @TableField(exist = false) private String roleName; private String remark; @TableField(exist = false) private List<Permission> authorities; public User() { } public User(Integer id){ super.setId(id); } public User(List<Permission> authorities, User user) { this.authorities = authorities; super.setId(user.getId()); super.setModifyDate(user.getModifyDate()); super.setCreateDate(user.getCreateDate()); username = user.getUsername(); password = user.getPassword(); realName = user.getRealName(); phone = user.getPhone(); email = user.getEmail(); status = user.getStatus(); departmentId = user.getDepartmentId(); authStartTime = user.getAuthStartTime(); authEndTime = user.getAuthEndTime(); } @Transient @Override public Collection<? extends GrantedAuthority> getAuthorities() { List<SimpleGrantedAuthority> auth = new ArrayList<>(); // 根据Permission生成权限列表 Optional.ofNullable(authorities) .ifPresent(p -> p.forEach(permission -> { auth.add(new SimpleGrantedAuthority(permission.getExpression())); })); return auth; } @Transient @Override public boolean isAccountNonExpired() { return true; } @Transient @Override public boolean isAccountNonLocked() { return true; } @Transient @Override public boolean isCredentialsNonExpired() { return true; } @Transient @Override public boolean isEnabled() { return true; }}
这是表结构
我把sql打印出来,拿来数据库里执行,都是能正常查出来的,说明单独跟pgsql没有关系,估计就是pgsql跟mybatisplus集成上的问题。而且也只有这一个字段出不来,并且也不是每条数据的这个字段出不来。
以上就是关于“mybatisplus+pgsql查询bug怎么解决”这篇文章的内容,相信大家都有了一定的了解,希望小编分享的内容对大家有帮助,若想了解更多相关的知识内容,请关注编程网行业资讯频道。