栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

【亲测好使】Error querying database. Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

【亲测好使】Error querying database. Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException

现象如下,两方面原因:

1.@Select注解里面sql或者mapper.xml的sql错误。

2.如果sql确认没错,还有一个原因是javabean里面使用了mysql的关键词,造成解析错误,解决方式,是javabean中添加注册

@TableField("`global`")
private Boolean global;

@TableField("`status`")
private Boolean status;

扩展:https://download.csdn.net/course/detail/37057https://download.csdn.net/course/detail/37057

https://download.csdn.net/course/detail/37510https://download.csdn.net/course/detail/37510

类似这种。

package com.qi.rbac.entity;

import java.util.Date;
import java.io.Serializable;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;


@TableName(value = "sys_resource")
public class SysResource implements Serializable {
    private static final long serialVersionUID = 206296861120689444L;
    
    private Long id;
    
    private String label;
    
    private String treePath;
    
    private String permission;
    
    private Long parentId;
    
    private String path;
    
    private String component;
    
    private Integer sequence;
    
    private String icon;
    
    private String style;
    
    private Integer type;
    
    @TableField("`status`")
    private Boolean status;
    
    private Boolean readonly;
    
    @TableField("`global`")
    private Boolean global;
    
    private Boolean display;
    
    private String description;
    
    private Long createdBy;
    
    private String createdName;
    
    private Date createdTime;
    
    private Long lastModifiedBy;
    
    private String lastModifiedName;
    
    private Date lastModifiedTime;


    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public String getTreePath() {
        return treePath;
    }

    public void setTreePath(String treePath) {
        this.treePath = treePath;
    }

    public String getPermission() {
        return permission;
    }

    public void setPermission(String permission) {
        this.permission = permission;
    }

    public Long getParentId() {
        return parentId;
    }

    public void setParentId(Long parentId) {
        this.parentId = parentId;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public String getComponent() {
        return component;
    }

    public void setComponent(String component) {
        this.component = component;
    }

    public Integer getSequence() {
        return sequence;
    }

    public void setSequence(Integer sequence) {
        this.sequence = sequence;
    }

    public String getIcon() {
        return icon;
    }

    public void setIcon(String icon) {
        this.icon = icon;
    }

    public String getStyle() {
        return style;
    }

    public void setStyle(String style) {
        this.style = style;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public Boolean getStatus() {
        return status;
    }

    public void setStatus(Boolean status) {
        this.status = status;
    }

    public Boolean getReadonly() {
        return readonly;
    }

    public void setReadonly(Boolean readonly) {
        this.readonly = readonly;
    }

    public Boolean getGlobal() {
        return global;
    }

    public void setGlobal(Boolean global) {
        this.global = global;
    }

    public Boolean getDisplay() {
        return display;
    }

    public void setDisplay(Boolean display) {
        this.display = display;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Long getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(Long createdBy) {
        this.createdBy = createdBy;
    }

    public String getCreatedName() {
        return createdName;
    }

    public void setCreatedName(String createdName) {
        this.createdName = createdName;
    }

    public Date getCreatedTime() {
        return createdTime;
    }

    public void setCreatedTime(Date createdTime) {
        this.createdTime = createdTime;
    }

    public Long getLastModifiedBy() {
        return lastModifiedBy;
    }

    public void setLastModifiedBy(Long lastModifiedBy) {
        this.lastModifiedBy = lastModifiedBy;
    }

    public String getLastModifiedName() {
        return lastModifiedName;
    }

    public void setLastModifiedName(String lastModifiedName) {
        this.lastModifiedName = lastModifiedName;
    }

    public Date getLastModifiedTime() {
        return lastModifiedTime;
    }

    public void setLastModifiedTime(Date lastModifiedTime) {
        this.lastModifiedTime = lastModifiedTime;
    }

}

错误完整如下:

2022-06-29 00:01:24.530 - [] - ERROR 16176 --- [XNIO-1 task-1] com.qi.common.boot.base.GlobalExceptionHandler : [Mybatis 系统异常]

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Failed to process, Error SQL: SELECT  id,label,tree_path,permission,parent_id,path,component,sequence,icon,style,type,status,readonly,global,display,description,created_by,created_name,created_time,last_modified_by,last_modified_name,last_modified_time  FROM sys_resource 
 
 WHERe (parent_id = ? AND type = ?)
### Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Failed to process, Error SQL: SELECt  id,label,tree_path,permission,parent_id,path,component,sequence,icon,style,type,status,readonly,global,display,description,created_by,created_name,created_time,last_modified_by,last_modified_name,last_modified_time  FROM sys_resource 
 
 WHERe (parent_id = ? AND type = ?)
	at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:96)
	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441)
	at com.sun.proxy.$Proxy183.selectList(Unknown Source)
	at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:224)
	at com.baomidou.mybatisplus.core

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1003923.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号