spring boot - JpaRepository method having constructor expression and Optional return type cause ConverterNotFoundException -


i have jparepository method having constructor expression , java.util.optional return type.

@repository public interface testdatarepository extends jparepository<testdata, integer> {    @query("select new com.example.testdatasummary(d.id, d.col1) " +         "from testdata d d.id = ?1")   optional<testdatasummary> findoptionalandnewbyid(integer id); } 

this method makes org.springframework.core.convert.converternotfoundexception after updating spring-data-jpa 1.9.4.release 1.10.2.release.

stacktrace below.

no converter found capable of converting type [java.util.optional<?>] type [com.example.testdatasummary] org.springframework.core.convert.converternotfoundexception: no converter found capable of converting type [java.util.optional<?>] type [com.example.testdatasummary]     @ org.springframework.core.convert.support.genericconversionservice.handleconverternotfound(genericconversionservice.java:313)     @ org.springframework.core.convert.support.genericconversionservice.convert(genericconversionservice.java:195)     @ org.springframework.core.convert.support.genericconversionservice.convert(genericconversionservice.java:176)     @ org.springframework.data.repository.query.resultprocessor$projectingconverter.convert(resultprocessor.java:240)     @ org.springframework.data.repository.query.resultprocessor$chainingconverter$1.convert(resultprocessor.java:185)     @ org.springframework.data.repository.query.resultprocessor$chainingconverter.convert(resultprocessor.java:196)     @ org.springframework.data.repository.query.resultprocessor.processresult(resultprocessor.java:159)     @ org.springframework.data.jpa.repository.query.abstractjpaquery.doexecute(abstractjpaquery.java:107)     @ org.springframework.data.jpa.repository.query.abstractjpaquery.execute(abstractjpaquery.java:92)     @ org.springframework.data.repository.core.support.repositoryfactorysupport$queryexecutormethodinterceptor.doinvoke(repositoryfactorysupport.java:482)     @ org.springframework.data.repository.core.support.repositoryfactorysupport$queryexecutormethodinterceptor.invoke(repositoryfactorysupport.java:460)     @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:179)     @ org.springframework.data.projection.defaultmethodinvokingmethodinterceptor.invoke(defaultmethodinvokingmethodinterceptor.java:61)     @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:179)     @ org.springframework.transaction.interceptor.transactioninterceptor$1.proceedwithinvocation(transactioninterceptor.java:99)     @ org.springframework.transaction.interceptor.transactionaspectsupport.invokewithintransaction(transactionaspectsupport.java:280)     @ org.springframework.transaction.interceptor.transactioninterceptor.invoke(transactioninterceptor.java:96)     @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:179)     @ org.springframework.dao.support.persistenceexceptiontranslationinterceptor.invoke(persistenceexceptiontranslationinterceptor.java:136)     @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:179)     @ org.springframework.data.jpa.repository.support.crudmethodmetadatapostprocessor$crudmethodmetadatapopulatingmethodinterceptor.invoke(crudmethodmetadatapostprocessor.java:133)     @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:179)     @ org.springframework.aop.interceptor.exposeinvocationinterceptor.invoke(exposeinvocationinterceptor.java:92)     @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:179)     @ org.springframework.aop.framework.jdkdynamicaopproxy.invoke(jdkdynamicaopproxy.java:213)     @ com.sun.proxy.$proxy73.findoptionalandnewbyid(unknown source)     @ com.example.optionalandnewtest._03_testoptionalandnew(optionalandnewtest.java:76)     @ sun.reflect.nativemethodaccessorimpl.invoke0(native method)     @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62)     @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43)     @ java.lang.reflect.method.invoke(method.java:498)     @ org.junit.runners.model.frameworkmethod$1.runreflectivecall(frameworkmethod.java:50)     @ org.junit.internal.runners.model.reflectivecallable.run(reflectivecallable.java:12)     @ org.junit.runners.model.frameworkmethod.invokeexplosively(frameworkmethod.java:47)     @ org.junit.internal.runners.statements.invokemethod.evaluate(invokemethod.java:17)     @ org.junit.internal.runners.statements.runbefores.evaluate(runbefores.java:26)     @ org.springframework.test.context.junit4.statements.runbeforetestmethodcallbacks.evaluate(runbeforetestmethodcallbacks.java:75)     @ org.springframework.test.context.junit4.statements.runaftertestmethodcallbacks.evaluate(runaftertestmethodcallbacks.java:86)     @ org.springframework.test.context.junit4.statements.springrepeat.evaluate(springrepeat.java:84)     @ org.junit.runners.parentrunner.runleaf(parentrunner.java:325)     @ org.springframework.test.context.junit4.springjunit4classrunner.runchild(springjunit4classrunner.java:252)     @ org.springframework.test.context.junit4.springjunit4classrunner.runchild(springjunit4classrunner.java:94)     @ org.junit.runners.parentrunner$3.run(parentrunner.java:290)     @ org.junit.runners.parentrunner$1.schedule(parentrunner.java:71)     @ org.junit.runners.parentrunner.runchildren(parentrunner.java:288)     @ org.junit.runners.parentrunner.access$000(parentrunner.java:58)     @ org.junit.runners.parentrunner$2.evaluate(parentrunner.java:268)     @ org.springframework.test.context.junit4.statements.runbeforetestclasscallbacks.evaluate(runbeforetestclasscallbacks.java:61)     @ org.springframework.test.context.junit4.statements.runaftertestclasscallbacks.evaluate(runaftertestclasscallbacks.java:70)     @ org.junit.runners.parentrunner.run(parentrunner.java:363)     @ org.springframework.test.context.junit4.springjunit4classrunner.run(springjunit4classrunner.java:191)     @ org.gradle.api.internal.tasks.testing.junit.junittestclassexecuter.runtestclass(junittestclassexecuter.java:112)     @ org.gradle.api.internal.tasks.testing.junit.junittestclassexecuter.execute(junittestclassexecuter.java:56)     @ org.gradle.api.internal.tasks.testing.junit.junittestclassprocessor.processtestclass(junittestclassprocessor.java:66)     @ org.gradle.api.internal.tasks.testing.suitetestclassprocessor.processtestclass(suitetestclassprocessor.java:51)     @ sun.reflect.nativemethodaccessorimpl.invoke0(native method)     @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62)     @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43)     @ java.lang.reflect.method.invoke(method.java:498)     @ org.gradle.messaging.dispatch.reflectiondispatch.dispatch(reflectiondispatch.java:35)     @ org.gradle.messaging.dispatch.reflectiondispatch.dispatch(reflectiondispatch.java:24)     @ org.gradle.messaging.dispatch.contextclassloaderdispatch.dispatch(contextclassloaderdispatch.java:32)     @ org.gradle.messaging.dispatch.proxydispatchadapter$dispatchinginvocationhandler.invoke(proxydispatchadapter.java:93)     @ com.sun.proxy.$proxy2.processtestclass(unknown source)     @ org.gradle.api.internal.tasks.testing.worker.testworker.processtestclass(testworker.java:109)     @ sun.reflect.nativemethodaccessorimpl.invoke0(native method)     @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62)     @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43)     @ java.lang.reflect.method.invoke(method.java:498)     @ org.gradle.messaging.dispatch.reflectiondispatch.dispatch(reflectiondispatch.java:35)     @ org.gradle.messaging.dispatch.reflectiondispatch.dispatch(reflectiondispatch.java:24)     @ org.gradle.messaging.remote.internal.hub.messagehub$handler.run(messagehub.java:364)     @ org.gradle.internal.concurrent.executorpolicy$catchandrecordfailures.onexecute(executorpolicy.java:54)     @ org.gradle.internal.concurrent.stoppableexecutorimpl$1.run(stoppableexecutorimpl.java:40)     @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1142)     @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:617)     @ java.lang.thread.run(thread.java:745) 

i make simple test in repository.

https://github.com/sis-yoshiday/hopper-sr2_optionalandnew

// build.gradle ext {   springdataversion = 'hopper-sr2'   //springdataversion = 'gosling-sr4' } 

i tried change spring-data-jpa release-train version , execute test. result is...

  • hopper-sr2 : error
  • gosling-sr4 : ok

anyone know why ?

p.s 2016/08/18

it fixed hopper-sr3


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -