java.lang.NullPointerException
at com.slyak.spring.jpa.FreemarkerTemplateQuery.createJpaQuery(FreemarkerTemplateQuery.java:116)
at com.slyak.spring.jpa.FreemarkerTemplateQuery.doCreateQuery(FreemarkerTemplateQuery.java:53)
at org.springframework.data.jpa.repository.query.AbstractJpaQuery.createQuery(AbstractJpaQuery.java:190)
at org.springframework.data.jpa.repository.query.JpaQueryExecution$CollectionExecution.doExecute(JpaQueryExecution.java:121)
at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:85)
at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:116)
at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:106)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:483)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:461)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:56)
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 com.slyak.spring.jpa.GenericJpaRepositoryFactory$AssemblerInterceptor.invoke(GenericJpaRepositoryFactory.java:121)
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.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:57)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
public Query createJpaQuery(String queryString) {
Class<?> objectType = getQueryMethod().getReturnedObjectType();
//get original proxy query.
Query oriProxyQuery;
//must be hibernate QueryImpl
QueryImpl query;
if (useJpaSpec && getQueryMethod().isQueryForEntity()) {
oriProxyQuery = getEntityManager().createNativeQuery(queryString, objectType);
// QueryImpl query = AopTargetUtils.getTarget(oriProxyQuery);
} else {
oriProxyQuery = getEntityManager().createNativeQuery(queryString);
query = AopTargetUtils.getTarget(oriProxyQuery);
//find generic type
ClassTypeInformation<?> ctif = ClassTypeInformation.from(objectType);
//FreemarkerTemplateQuery.java:116 ctif对象为null
TypeInformation<?> actualType = ctif.getActualType();
Class<?> genericType = actualType.getType();
if (genericType != null && genericType != Void.class) {
QueryBuilder.transform(query.getHibernateQuery(), genericType);
}
}
//return the original proxy query, for a series of JPA actions, e.g.:close em.
return oriProxyQuery;
}