JPA错误之Failed to convert from type [java.lang.Object[]] to type

问题背景

同事遇到一个奇怪的报错“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.ReflectiveMeth

 

解决方案
出现该错误的原因可能是你在当前的Repository里面,查询了其他的实体,例如这是一个QueueRepository extends JpaRepository<Queue, Integer>,然后你去查询Wicket,那肯定GG的,每个实体要都要有一个对应的XXXRepository来执行CRUD操作的。实体Entity跟Repository层内容要对应,检查一下即可。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Learn to use the Java Persistence API (JPA) and other related APIs as found in the Java EE 8 platform from the perspective of one of the specification creators. A one-of-a-kind resource, this in-depth book provides both theoretical and practical coverage of JPA usage for experienced Java developers. Authors Mike Keith, Merrick Schincariol and Massimo Nardone take a hands-on approach, based on their wealth of experience and expertise, by giving examples to illustrate each concept of the API and showing how it is used in practice. The examples use a common model from an overarching sample application, giving you a context from which to start and helping you to understand the examples within an already familiar domain. After completing Pro JPA 2 in Java EE 8, you will have a full understanding of JPA and be able to successfully code applications using its annotations and APIs. The book also serves as an excellent reference guide. What You Will LearnUse the JPA in the context of enterprise applications Work with object relational mappings (ORMs), collection mappings and more Build complex enterprise Java applications that persist data long after the process terminates Connect to and persist data with a variety of databases, file formats, and more Use queries, including the Java Persistence Query Language (JPQL) Carry out advanced ORM, queries and XML mappings Package, deploy and test your Java persistence-enabled enterprise applications Who This Book Is For Experienced Java programmers and developers with at least some prior experience with J2EE or Java EE platform APIs.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值