Jpa自定义查询报错(Failed to convert from type [java.lang.Object[]] to type)
Jpa自定义查询报错
问题背景
今天遇到一个奇怪的报错“Failed to convert from type [java.lang.Object[]] to type”,这个报错,百度上也是很少的,恰恰是这样的问题,引起我了解决的欲望。先看看报错:
org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.Object[]] to type [org.microservice.tcbj.yytsg.checksys.entity.Wicket] for value '{1, 7, C1, 1, 7, 1}'; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.Integer] to type [org.microservice.tcbj.yytsg.checksys.entity.Wicket]
at org.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:46)
at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:191)
at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:174)
at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:108)
at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:136)
at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:125)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:590)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:578)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:59)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:294)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvo
在网上找了很多解决方案,多是要改变Springboot的配置,然而给便配置我肯定是不愿意的,于是经过千辛万苦,终于找到了解决方案。
出现该错误的原因可能是你在当前的Repository里面,查询了其他的实体,例如你在UserRepository extends JpaRepository<UserEntity,Integer>里面去自定义了一个查询,该查询返回的实体是CarEntity,那就会报这样的转换错误,每个实体要都要有一个对应的XXXRepository来执行CRUD操作的。实体Entity跟Repository层内容要对应,解决方案就是将这个自定义查询剪切到对应的Repository里面。
Jpa自定义查询报错(Failed to convert from type [java.lang.Object[]] to type)的更多相关文章
- 【spring boot】spring boot 前台GET请求,传递时间类型的字符串,后台无法解析,报错:Failed to convert from type [java.lang.String] to type [java.util.Date]
spring boot 前台GET请求,传递时间类型的字符串,后台无法解析,报错:Failed to convert from type [java.lang.String] to type [jav ...
- zepplin0.7.2报错ERROR, exception: null, result: %text java.lang.NullPointerException的处理
zepplin0.7.2报错ERROR, exception: null, result: %text java.lang.NullPointerException的处理 问题描述: 使用zeppli ...
- Failed to convert from type [java.lang.String] to type [java.util.Date] for value '2020-02-06'; nested exception is java.lang.IllegalArgumentException]解决
今天做springbook项目前端输入日期传到数据库保存报了一下错误 Whitelabel Error Page This application has no explicit mapping fo ...
- 【Xamarin报错】 COMPILETODALVIK : UNEXPECTED TOP-LEVEL error java.lang.OutOfMemoryError: Java heap space
Xamarin Android 编译报错: COMPILETODALVIK : UNEXPECTED TOP-LEVEL error java.lang.OutOfMemoryError: Java ...
- 完美解决报错Failed to convert value of type 'java.lang.String' to required type 'java.util.Date'
Failed to convert value of type 'java.lang.String' to required type 'java.util.Date' 首先这个错误的意思是 前台页面 ...
- 关于myeclipse启动报错:An internal error has occurred. java.lang.NullPointerException解决办法
启动myeclipse报错,百度了一下网友处理方式,对比日志,发现现在已有的教程真的是巨人坑: 如果出现了上述的错误按照如下的3个步骤解决:1.首先关闭MyEclipse工作空间.2.然后删除工作空间 ...
- spark-shell报错:Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/fs/FSDataInputStream
环境: openSUSE42.2 hadoop2.6.0-cdh5.10.0 spark1.6.0-cdh5.10.0 按照网上的spark安装教程安装完之后,启动spark-shell,出现如下报错 ...
- 报错:Exception in thread "main" java.lang.NoClassDefFoundError: Lorg/apache/hadoop/fs/FileSystem
报错现象: Exception in thread "main" java.lang.NoClassDefFoundError: Lorg/apache/hadoop/fs/Fil ...
- idea 运行scala代码 报错:Exception in thread "main" java.lang.NoClassDefFoundError: scala/Predef$ java.lang.NoClassDefFoundError: scala/Function0 Error: A JNI error has occurred, please check your installati
各种报错信息如下: java.lang.NoClassDefFoundError: scala/Function0 at java.lang.Class.getDeclaredMethods0(Nat ...
随机推荐
- Project Euler Problem 12-Highly divisible triangular number
最直接的想法就是暴力搞搞,直接枚举,暴力分解因子.再好一点,就打个素数表来分解因子.假设num=p1^a1p2^a2...pn^an,则所有因子个数为(a1+1)(a2+1)...(an+1). 再好 ...
- python实用工具包
文本处理 FlashText 大规模关键字搜索利器,据说多余500个关键字时性能会明显优于正则表达式,暂未评测! 调试利器 pysnooper 不需要使用print进行调试
- 上传图片保存到MySql数据库并显示--经验证有效
以下方法仅供参考,只是介绍下这一种方法而已.欢迎指正!! 前台(image.html): 1<html> 2<head> 3<title>上传图片</tit ...
- js用for循环模拟数组翻转
文章地址 https://www.cnblogs.com/sandraryan/ js本身为数组提供了reverse()方法,可以翻转数组,返回一个新的数组,不影响原数组. 本例中用for循环简单模拟 ...
- tensorflow op tf.global_variables_initializer
一.安装目前用了tensorflow.deeplearning4j两个深度学习框架, tensorflow 之前一直支持到python 3.5,目前以更新到3.6,故安装最新版体验使用. 慢慢长征路: ...
- vue v-for循环中key属性的使用
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 2018-4-29-C#-将dll打包到程序中
title author date CreateTime categories C# 将dll打包到程序中 lindexi 2018-04-29 09:43:22 +0800 2018-2-13 17 ...
- Vue-axios 在vue cli中封装
common/post.js import axios from 'axios' // 引入axios import qs from 'qs' // 引入qs axios.defaults.baseU ...
- 11-28\enum
1.创建一个枚举对象,对象中4个属性video视频.book书----(这2个属性可以用数字表示). 2.创建一个class对象,对象中有2个属性,一个是id属性(自己设置),第二个属性是type类型 ...
- visual studio 2010问题修复
我在重新安装 Visual Studio 2010 和 SQL sever 2012 的时候,安装好的两个软件打开时都遇到了这个问题:“在此计算机中仅有部分 Microsoft Visual Stud ...