首页 > 其他分享 >Mybatis-puls中select查询方法报错Can not find table primary key in Class

Mybatis-puls中select查询方法报错Can not find table primary key in Class

时间:2024-08-29 16:26:16浏览次数:5  
标签:填充 查询方法 primary 主键 Mybatis 报错 类型 type ID

1、项目参数

springboot 2.6.13

jdk8

Mybatis-Plus3.5.4

2、问题描述

Mybatis-puls中select查询方法报错Can not find table primary key in Class,

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.example.dao.FLowerDao.selectById

3、问题原因

表里有主键,但是报找不到主键,因为mybatis plus 里面自动匹配主键字段为id

当数据库中的主键不为id时会报出上述错误。

解决:

添加下面代码

@TableId(value = "flower_id",type = IdType.INPUT)

value:设置数据库字段值
type:设置主键类型、用户输入ID(该类型可以通过自己注册自动填充插件进行填充)建议使用INPUT

type有六种类型类型,最下面三个只有插入主键为空时,才会自动填充,可根据数据表主键类型自行选择合适的type类型

类型 解释
AUTO 数据库自增ID
NONE 数据库未设置主键类型(将会跟随全局)
INPUT 用户输入ID(该类型可以通过自己注册自动填充插件进行填充)
ID_WORKER 全局唯一ID(idWorker)
UUID 全局唯一ID(UUID)
ID_WORKER_STR 字符串全局唯一ID(idWorker 的字符串表示)

标签:填充,查询方法,primary,主键,Mybatis,报错,类型,type,ID
From: https://www.cnblogs.com/wei-jing/p/18386898

相关文章

  • Mybatis-puls中select查询方法返回为空null
    1、项目参数springboot2.6.13jdk8Mybatis-Plus3.5.42、问题描述在3.5.4版本的MP中使用select方法查询到数据,却返回为空实体类publicclassFlower{@TableId(value="flower_id",type=IdType.INPUT)privateintflower_id;privateStringflower_name;......
  • 训练yolov5时出现报错:AttributeError: ‘FreeTypeFont‘ object has no attribute ‘g
    报错:Traceback(mostrecentcalllast):File"D:\anaconda3_xz\envs\luopytorch\lib\threading.py",line932,in_bootstrap_innerself.run()File"D:\anaconda3_xz\envs\luopytorch\lib\threading.py",line870,inrunself._target(*s......
  • gyp GET https://nodejs.org/download/release/v20.15.0/node-v20.15.0-headers.tar.g
    如图我执行yarn关于node会报错:gyphttpGEThttps://nodejs.org/download/release/v20.15.0/node-v20.15.0-headers.tar.gzgyphttpfetchGEThttps://nodejs.org/download/release/v20.15.0/node-v20.15.0-headers.tar.gzattempt1failedwithETIMEDOUTgypWARNins......
  • No module named 'mininet.cli'报错处理
    Nomodulenamed'mininet.cli'报错处理问题描述在命令行中输入python,在解释器中执行frommininet.cliimportCLI不会报错的前提下,使用makerun编译运行程序时,出现如下报错:Traceback(mostrecentcalllast):File"../../utils/run_exercise.py",line29,in<module>......
  • databaseId 不匹配导致Mybayis报错:Invalid bound statement (not found)
    问题后端调用Mapper方法报错:Invalidboundstatement(notfound)排查过程按网上方式逐一排查,都未解决问题网上搜不到解决方案,只能查看源码了首先定位到com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean#buildSqlSessionFactory方法打上一个条件断......
  • 安卓11报错:Failed to resolve: com.github.xxxx:14.0 Show in Project Structure dial
    本篇文章主要讲解,安卓11版本情况下项目运行报错Failedtoresolve:com.github.getActivity:Toaster:14.0ShowinProjectStructuredialogAffectedModules:app的主要原因及解决办法。作者:任聪聪独立博客:https://rccblogs.com/631.html日期:2024年8月28日具体......
  • HBuilderX运行报错,一直是“正在下载XX插件”
    一、HBuilderX简介:HBuilderX简称HX,HBuilder,H是HTML的缩写,Builder是建设者。是为前端开发者服务的通用IDE,或者称为编辑器。与vscode、sublime、webstorm类似。它可以开发普通web项目,也可以开发DCloud出品的uni-app项目、5+App项目、wap2app项目。目前有500......
  • docker 安装后第一次启动时报错
    启动服务:systemctlstartdocker发生错误未能启动查看日志:systemctlstatusdockerjournalctl-xe发现错误:DependencyfailedforDockerApplicationContainerEngine.应该是有依赖服务未启动成功查看依赖服务:systemctllist-dependenciesdocker.service发现是docker.s......
  • ptrade排坑日记——交易策略报错: ‘NoneType‘ object is not subscriptable 。
    前言今天要和大家分享的一个问题是交易策略报错,希望大家在使用ptrade过程中遇见这个问题能够快速解决!一、问题描述交易策略报错: File"/home/fly/sim_backtest/result/412974e0-a014-11ee-8735-d4f5ef8c353c/user_strategy.py",line354,inocall_BS  px_change_ra......
  • 【python3.8安装报错】lmportError: DLL load failed while importing ft2font: 找不
    客户需求背景:安装python3.8无法运行,报错lmportError:DLLloadfailedwhileimportingft2font:找不到指定的模块 考虑兼容性问题这个问题首先需要考虑的是是否是python版本太高了,因为python3.9不支持win7,而python3.8版本对win7的兼容性也有一定的限制。解决:首先考......