Blaze Persistence CTE query throws ClassCastException on QuerySqmImpl

25 Views Asked by At

I'm trying to implement a simple CTE query with Blaze Persistence based on the documentation and some examples found on the net :

List postCriteriaBuilder = criteriaBuilderFactory.create(entityManager, Object.class)
   .fromSubquery(PostHolderCte.class, "cte")
   .from(Post.class, "pp")
     .bind("postId").select("pp.id")
   .end()
   .joinOn(Post.class, "pp", JoinType.INNER).onExpression("pp.id = cte.postId").end()
   .select("pp.id")
   .getResultList()
   ;

But it throws the following :

java.lang.ClassCastException: class jdk.proxy2.$Proxy349 cannot be cast to class org.hibernate.query.sqm.internal.QuerySqmImpl (jdk.proxy2.$Proxy349 is in module jdk.proxy2 of loader 'app'; org.hibernate.query.sqm.internal.QuerySqmImpl is in unnamed module of loader 'app')
at com.blazebit.persistence.integration.hibernate.base.HibernateExtendedQuerySupport.getSql(HibernateExtendedQuerySupport.java:221)
at com.blazebit.persistence.impl.query.DefaultQuerySpecification.getSql(DefaultQuerySpecification.java:68)
at com.blazebit.persistence.impl.AbstractCommonQueryBuilder.collectEntityFunctionNodes(AbstractCommonQueryBuilder.java:3142)
at com.blazebit.persistence.impl.AbstractCommonQueryBuilder.collectEntityFunctionNodes(AbstractCommonQueryBuilder.java:2975)
at com.blazebit.persistence.impl.AbstractCommonQueryBuilder.collectEntityFunctionNodes(AbstractCommonQueryBuilder.java:2958)
at com.blazebit.persistence.impl.AbstractCommonQueryBuilder.getEntityFunctionNodes(AbstractCommonQueryBuilder.java:2947)
at com.blazebit.persistence.impl.AbstractCommonQueryBuilder.getTypedQuery(AbstractCommonQueryBuilder.java:2895)
at com.blazebit.persistence.impl.AbstractQueryBuilder.getQuery(AbstractQueryBuilder.java:53)
at com.blazebit.persistence.impl.AbstractQueryBuilder.getResultList(AbstractQueryBuilder.java:58)
at com.test.MyRepository...

The query is executed in a SpringBoot 3.2.2 application, the other notable Blazebit dependencies are :

        <dependency>
            <groupId>com.blazebit</groupId>
            <artifactId>blaze-persistence-core-api-jakarta</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.blazebit</groupId>
            <artifactId>blaze-persistence-core-impl-jakarta</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>com.blazebit</groupId>
            <artifactId>blaze-persistence-integration-hibernate-6.2</artifactId>
            <scope>runtime</scope>
        </dependency>

blaze-persistence.version is 1.6.11

I tried other variants of CTE queries including implementations with blaze persistence Querydsl but the same exception was thrown.

Is this something related to Blaze Persistence or rather a Hibernate issue ?

0

There are 0 best solutions below