【发布时间】:2021-10-23 23:22:00
【问题描述】:
我有这个问题:
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
我正在尝试通过 Spring 使用 Java 中的 QueryDSL,其中我的一种方法包含:
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();
抛出以下异常 -> com.querydsl.jpa.impl.JPAQuery 无法转换为 com.querydsl.core.types.EntityPath
我能做些什么来解决它?
【问题讨论】:
标签: java mysql spring jpa querydsl