Can't compare test expression of type [CommodityEntity] with element of type [BasicSqmPathSource(materialId : Integer)]

SELECT m.materialId,m.materialName,m.materialShortName, subq.locationId " +
" FROM CommodityEntity m " +
" JOIN (" +
" SELECT lc.materialId AS materialId, ls.locationId AS locationId,COUNT(lc.materialId) AS FREQ " +
" FROM LogisticsCargoScheDuleEntity lcs " +
" JOIN lcs.logisticsCargoId lc " +
“JOIN lc.logisticsVoyageId lv “+
" JOIN lcs.logisticsScheduleId ls” +
" WHERE (lv.userUpdatedBy = :userId OR lv.userNominationBy = :userId OR lv.userFixedBy = :userId)” +
" GROUP BY lc.materialId,ls.locationId) " +
" AS subq ON subq.materialId = m.materialId " +
" ORDER BY subq.freq DESC

Caused by: java.lang.IllegalArgumentException: Can’t compare test expression of type [CommodityEntity] with element of type [BasicSqmPathSource(materialId : Integer)]

This is a duplicate of your other post Regarding Subquery in JPQL,please help me on this.