Expected one result (or null) to be returned by selectOne(), but found: 28

mybatis报错:Expected one result (or null) to be returned by selectOne(), but found: 2 springboot集成mybatis报错:Expected one result (or null) to be returned by selectOne(), but found: 2 阅读详情

Expected one result (or null) to be returned by selectOne(), but found: 28解决方案

作为一个初学者,我在用SSM框架查询数据库时报了这个错误。在这里记录一下我出现这个问题的原因。
根据业务需求,我应当返回“一堆”数据库查询到的数据,但我用来接收的却是返回单个对象的自定义类型。

因此只要将自己定义的类型设为泛型,返回 List<自定义类型> 问题就解决了。

多种方法解决Expected one result (or null) to be returned by selectOne(), but found: x 的错误 多种方法解决org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 2或者Expected one result (or null) to be returned by getOne的错误。 阅读详情

相关推荐

火车头采集器超级详细图文使用指导(面向新手)

火车采集器·超级详细使用指导

DE的个人原创笔记 1万+

解决:TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found:

通过分析错误可知:需要的查询出一条数据,但是结果却大相径庭,出现的是多条结果(只要不是一条结果就是多条结果),从而应发了TooManyResultsException 错误。 错误截图: 由出现的事故来看,很有可能是 Sql 语句或者数据库方面的问题,从这个地方开始着手,分析我们的问题: 先看一下 resultType 是不是我们对应的数据类型: 你我的问题出现的方式可能不是一样的,所以先检查看看是不是你需要返回的数据类型,同时看看你的 dao 层 接口的返回值类型改了没有。 我的.

潘小蓝的博客 5万+

数据仓库实践:从ITR流程讲指标体系建设

从 ITR 流程或者其他客服反馈流程的考核过程可见,实际工作中不可能只通过单个指标评价一个业务过程,需要从多个维度梳理业务,并把多个高度相关的指标组织起来,以避免只考虑其中某个指标从而摧毁整个业务过程的结果,指标体系=指标+体系。

the_singing_towers的博客 2265

mybatis报错:Expected one result (or null) to be returned by selectOne(), but found: 28

自动选择selectOne()方法,由于只能返回一个对象的结果,当返回到多个对象的结果时报错。getUser是一个student类的bean无法接受多个结果,则改用List就可以接受多个结果 将返回类型改为List

weixin_39148913的博客 535

【MFiX后处理】MFiX中使用des_usr_var输出颗粒的传热量(2020-11-27更新变更输出变量名方法)

参考之前Yin的那一篇博客 https://www.cnblogs.com/Jay-CFD/p/10621274.html 输出一下颗粒传热量 使用的算例是fluid_bed_dem_2d 打开des scalar tracking 前面都和Yin那篇一样,打开enable user scalar tracking 输入2 因为第一个用来测试Y加速度了 第二个输出传热量 然后在output vtk中勾选好 更改源代码 源代码为des_thermo_newvalues.f 在mfix-GUI自带的ed

beidou111的博客 1532

探索Vortex开源GPGPU:RISC-V SIMT架构(2),指令Decode

本文分析了Vortex RISC-V内核的Decode模块设计。文章详细介绍了指令译码过程,包括操作码、功能码和寄存器字段的提取,以及不同类型指令(R/I/S/B/U/UJ)的立即数处理。重点阐述了基于操作码和功能码的分层译码逻辑,包括ALU运算、分支跳转、系统调用等指令的译码规则。此外,还描述了定制指令的处理机制以及与调度器的握手协议。Decode模块通过组合逻辑实现快速译码,并将结果传递给下级Issue模块,同时协调指令流控制。

weixin_55313207的博客 1792

【无标题】Expected one result (or null) to be returned by selectOne(), but found: 8报错原因及解决

Expected one result (or null) to be returned by selectOne(), but found: 8

yinhaoq的博客 1312

Qt Installer Framework4.6.1的最基础使用1(win10+离线安装包 )

因工作需要,win程序发布后,打包成一可执行exe文件,且兼容win7系统笔者记录了一些关键要点,供有需要的小伙伴使用。

aggs1990的专栏 904

HTTP Status 500 – Internal Server Error Type Expected one result (or null) to be returned...........

错误 HTTP Status 500 – Internal Server Error Type 异常报告 消息 Expected one result (or null) to be returned by selectOne(), but found: 8 描述 服务器遇到一个意外的情况,阻止它完成请求。 Exception org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be r

DYSLzx的博客 1111

Windows版TASSEL5的下载及安装

TASSEL5是一款用于研究表型和基因型关系的软件,由美国康奈尔大学Buckler实验室所研发。,选择Windows环境安装包下载并安装。1.安装成功后TASSEL5界面。

沉香best的博客 8188

数据分享|1961-2017年中国0.25°×0.25° 逐日地表水文数据集(VIC-CN05.1)

其中,全球径流中心(University of New Hampshire and Global Runoff Data Centre, UNH/GRDC)的复合产流场集成了观测的河道径流和水量平衡模式模拟的地表和地下径流,常被用来评估模拟的径流。在长白山、海北灌丛和千烟洲通量站,模拟与观测的逐月潜热通量的平均NSE为0.61。VIC-CN05.1受益于较准确的大气驱动场、先进的地表水文参数化方案以及更真实丰富的土壤信息,可作为中国水文气象研究的参照数据,用于陆面模式的评估和长期的趋势分析等。

J_Giser的博客 1830

Expected one result (or null) to be returned by selectOne(), but found: 2

看到标题就已经很明了了: 两种情况: 1.你想查询一条数据,但返回两条数据: 2.你想查询多条数据,但是前台限制只能查询一条 (1) 检查自己的数据sql语句写对没有(关于mybaties的sql操作自己百度) (2) 查看mybaties的返回值(resultType或resultMap),可以返回list,map等数据 (3)  dao层接口要与mybati

a1165117473的专栏 5569

YOLOv13|损失函数优化篇:Focal EIOU 保持良好性能的同时,提供更高效的计算和更稳定的训练过程-包源码

Focal IoU与EIoU:目标检测中的损失函数优化 摘要:本文深入探讨了目标检测中两种重要的边界框回归损失函数优化方法。Focal IoU借鉴Focal Loss思想,通过(1-IoU)^γ因子调节损失权重,使模型更关注难样本(低IoU预测框),有效解决了传统IoU Loss对难易样本权重相同的问题。EIoU则在CIoU基础上改进,通过简化长宽比计算、分离宽高损失项,提升了计算效率和训练稳定性。两种方法分别从样本权重分配和损失函数结构优化角度,显著提升了目标检测性能,为实际应用提供了更高效的解决方案。文

FJN110的博客 1864

MyBatis查询报错:Expected one result (or null) to be returned by selectOne(), but found: 2

MyBatis在查询数据时,查询涉及到多张表,且查询的对象存在集合的属性时,如下查询会报错:Expected one result (or null) to be returned by selectOne(), but found: 2 <resultMap id="classesMap" type="cn.jam.entity.Classes"> <id column="c.id" property="id"/> <result column="c.name

qq_33954947的博客 4977

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

Expected one result (or null) to be returned by selectOne(), but found: (不一定是sql语句返回值类型dao层问题)

如标题所讲, Expected one result (or null) to be returned by selectOne(), but found: 。。 简单明了的报错,一般人在一般情况下想到的就是 1.查询一条数据,但返回多条数据: 2.查询多条数据,但是前台限制只能查询一条 从而回去检查相关的sql语句,sql语句中的返回值,相关的dao层代码。从而获取相关的解决办法...

FlyRman的博客 3210

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Expected one result (or null) to be returned by selectOne(), but found: 3报错解决方案

Expected one result (or null) to be returned by selectOne(), but found: 3

weixin_51821844的博客 1万+

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

mybatis一对多映射 完美解决Expected one result (or null) to be returned by selectOne(), but found:

今天在进行mybatis学习时 出现了上述错误 在网上看了n篇文章都没有解决 下图是我查询用到的两个表 其中student表中的tid和teacher表中的id通过外键链接​ 在我的xml文件中 我刚开始是这么进行查询的 <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://myb...

TIANJIAWEN的博客 1万+

TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 3

123 public Object execute(SqlSession sqlSession, Object[] args) { Object result; switch (command.getType()) { case INSERT: { Object param = method.convertArgsToSqlCommandParam(args); result = rowCountResult(sqlSessio...

zhangm2020的博客 1942

TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 2

标题:org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 2 报错原因:mapper层本该接收一个对象,但是执行该方法的sql后,查询出多个符合条件的对象,导致mybatis框架报错,无

qq_41203107的博客 1万+

解决 Expected one result (or null) to be returned by selectOne(), but found: 2

这个问题同样是在前后端交换数据的时候遇到的一个问题,然后我通过有道翻译给他翻译了一下: 刚开始看到这个对于新手小白来说可能还不能准确的定位到自己的错误,但是这个错误很明显就是在告诉我们: 你想查询多条数据,但是前台限制只能查询一条 这个错误在刚开始并没有出现,是因为我们刚开始的时候可能只是为了测试在数据库中只插入了一条数据,但是随着业务的增加,我们在数据库中加入了新的数据,但是同样的后端...

立志欲坚不欲锐,成功在久不在速度 2万+

Expected one result (or null) to be returned by selectOne(), but found: 5

Expected one result (or null) to be returned by selectOne(), but found: 5 通常如果出现了这个异常的,一般是mybatis的mapper.xml文件中的sql标签的返回值类型(resultType)为HashMap、并且sql语句没有条件指定,才导致的异常。 原因 因为HashMap本身是一个集合,可以存放多个元素。但是,...

qq_43489671的博客 3331

java——Expected one result (or null) to be returned by selectOne(), but found: 2

这里写自定义目录标题欢迎使用Markdown编辑器新的改变功能快捷键合理的创建标题,有助于目录的生成如何改变文本的样式插入链接与图片如何插入一段漂亮的代码片生成一个适合你的列表创建一个表格设定内容居中、居左、居右SmartyPants创建一个自定义列表如何创建一个注脚注释也是必不可少的KaTeX数学公式新的甘特图功能,丰富你的文章UML 图表FLowchart流程图导出与导入导出导入 欢迎使用Ma...

最好的时光里 2299

Expected one result (or null) to be returned by selectOne(), but found

有好久一段时间没写mybatis的xml了,出现这样的问题,写一下加深印象。 错误分析: 这个错误是因为在从数据库查出多条数据,但是接收的时候只显示一个。 解决方案: 举个例子说明问题                                                       SELECT IFNULL(id,1)  FROM shop

yanguo110的博客 8723

mybatis plus分页查询报错Expected one result (or null) to be returned by selectOne(), but found: 10

mybatis plus分页查询报错Expected one result (or null) to be returned by selectOne(), but found: 10

HumorChen的博客 885

mybatis一对多映射时始终不能正确映射到实体类,报错:Expected one result (or null) to be returned by selectOne(),but found:

写下这篇博客时真的是痛哭流涕啊,因为有个bug真的让我茶不思,饭不香一整天!那就是 TooManyResultsException: Expected one result (or null) to be returned by selectOne(),but found:13 它的意思就是mybatis期待返回的是一条数据,但实际返回了多条数据。 下面看我的实体类代码,书和章节是一对多关系,所以...

qq_41536791的博客 4353
下一篇: html中无法使用split()的情况
Rayvers
博客等级 码龄7年 2粉丝 11原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值