I have this query:
select gf_storage_zone_type,
sum(numObjectPhysicalName) numObjects
from (
select gf_storage_zone_type,
count(distinct gf_object_physical_name) as numObjectPhysicalName
from t_kgov_kpi_streaming_object
group by gf_storage_zone_type,
gf_object_physical_name
order by gf_storage_zone_type
) as v
group by gf_storage_zone_type
I am trying to use QueryDSL in Java with Spring, where one of my methods contains:
NumberPath<Long> numObjectPhysicalName = Expressions.numberPath(Long.class, "numObjectPhysicalName");
NumberPath<Long> numObjects = Expressions.numberPath(Long.class, "numObjects");
QKpiRuleBoard qKpiRuleBoard = QKpiRuleBoard.kpiRuleBoard;
List<ObjectsByStorageZoneProjection> objectsByStorageZone = jpaQueryFactory
.select(Projections.constructor(ObjectsByStorageZoneProjection.class,
qKpiRuleBoard.storageZoneType,
numObjectPhysicalName.sum().as(numObjects)))
.from(JPAExpressions
.select(
Projections.constructor(ObjectsByStorageZoneProjection.class,
qKpiRuleBoard.storageZoneType,
qKpiRuleBoard.objectPhysicalName.countDistinct().count().as(numObjectPhysicalName)))
.from(qKpiRuleBoard)
.where(
qKpiRuleBoard.cutoffDate.eq(cutoffDate)
.and(qKpiRuleBoard.countryId.eq(countryId))
.and(qKpiRuleBoard.executionFrequencyType.eq(executionFrequencyType)))
.groupBy(
qKpiRuleBoard.storageZoneType,
qKpiRuleBoard.objectPhysicalName))
.groupBy(qKpiRuleBoard.storageZoneType)
.fetch();
Throwing the following exception -> com.querydsl.jpa.impl.JPAQuery cannot be cast to com.querydsl.core.types.EntityPath
What can I do to solve it?