2016-11-30 104 views
0

我們正在升級我們的庫,並將Spring從4.2.4升級到4.3.4,並將Spring數據從1.9.2升級到1.10.5。我們還使用Hibernate 5.2.5.Final與MySql DB進行交談。ConverterNotFoundException將Spring升級到4.3.4後

這樣做後,我們得到以下錯誤的春季轉換。

org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [org.javatuples.Pair<?, ?>] to type [my.namespace.Category]

而且它的這個回購通話。

@Query("select new org.javatuples.Pair(cpc.category, count(*)) from UnlinkedProductCategorization cpc where cpc.myField = ?1 group by cpc.category") Collection<Pair<Category,Long>> countByCategoryForContainer(MyFieldType selfContainer);

在此回購沒有任何變化,如果我們恢復到一切正常。我們還有其他的情況下,我們使用select new org.javatuples.Pair(someEntityHere, count(*))仍然有效,所以我無法弄清楚爲什麼升級會打破它。爲什麼它認爲它應該嘗試將Pair轉換爲Category,這實際上沒有意義。

這裏的調用堆棧只是我們的最後一個方法之後

org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [org.javatuples.Pair<?, ?>] to type [com.siftit.domain.core.category.Category] 
    at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:324) 
    at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:206) 
    at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:187) 
    at org.springframework.data.repository.query.ResultProcessor$ProjectingConverter.convert(ResultProcessor.java:256) 
    at org.springframework.data.repository.query.ResultProcessor$ChainingConverter$1.convert(ResultProcessor.java:201) 
    at org.springframework.data.repository.query.ResultProcessor$ChainingConverter.convert(ResultProcessor.java:212) 
    at org.springframework.data.repository.query.ResultProcessor.processResult(ResultProcessor.java:149) 
    at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:121) 
    at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:106) 
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:482) 
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:460) 
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) 
    at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61) 
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) 
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) 
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282) 
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) 
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) 
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136) 
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) 
    at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:133) 
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) 
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) 
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) 
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) 
    at com.sun.proxy.$Proxy89.countByCategoryForContainer(Unknown Source) 

回答

0

不能直接回答,但這裏有一些事情你應該看看/試試,這是長期的評論:

  1. 你說你有其他方法使用new Pair。那些簽名是怎樣的?

  2. 設置發生異常的中斷點並檢查它正在做什麼/正在做什麼。注意:

    a)也許有通過不同類加載器加載的Pair類或Category類的多個實例。

    B)可能的類型從數據庫中得到了什麼變化,就像現在越來越BigInts,而不是Long

  3. 隔離問題:直到你得到的東西複製您的項目,刪除一切不相關的問題這麼小,以至於它可以合理地複製到SO問題中。通常情況下,您會發現問題的方式很長,如果不是,我們會在這裏提供幫助。

相關問題