slyak / spring-data-jpa-extra

spring data jpa with template dynamic query (eg: freemarker,velocity etc.) like mybatis. The master branch already support springboot2+ spring5+
Apache License 2.0
400 stars 116 forks source link

测试用例不能正常运行 #31

Closed ssy341 closed 5 years ago

ssy341 commented 6 years ago
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;
    }
ssy341 commented 6 years ago

@stormning 2.1.2.release 从仓库里拉不下来,maven仓库只有2.1.1 image

stormning commented 5 years ago

已补传到中央仓库