HQL group by eror

SELECT
                	NEW cn.topiam.employee.common.entity.app.po.AppAccessPolicyPO(a.id,
                	a.appId,
                	a.subjectId,
                	a.subjectType,
                	a.enabled,
                	a.createTime,
                    CONCAT( '[', LISTAGG( DISTINCT CONCAT('{"id":"', ame.id, '","name":"', ame.name, '","path":"', ame.path, '","parentId":"', ame.parentId,'"}'), ',' ), ']' ),
                	subject.name,
                	app.name,
                	app.icon,
                	app.type,
                	app.template,
                	app.protocol)
                FROM
                	AppAccessPolicyEntity a
                	INNER JOIN AppEntity app ON a.appId = app.id
                    INNER JOIN AppAccessMenuEntity ame ON ame.appId = a.appId
                INNER JOIN
                (
                SELECT
                    id as id,
                	name as name
                FROM
                	UserGroupEntity UNION ALL
                SELECT
                	id as id,
                	name as name
                FROM
                	OrganizationEntity UNION ALL
                SELECT
                	id as id,
                	username AS name
                FROM
                	UserEntity
                	) subject ON a.subjectId = subject.id
                WHERE 1=1 
GROUP BY a, app ,subject

error:

org.springframework.dao.InvalidDataAccessApiUsageException: org.hibernate.query.SemanticException: The derived SqmFrom[id, name] can not be used in a context where the expression needs to be expanded to identifying parts, because a derived model part does not have identifying parts. Replace uses of the root with paths instead e.g. `derivedRoot.get("alias1")` or `derivedRoot.alias1`

The error is pretty self-explanatory: you are using a derived root subject in the group-by clause, and since it’s not an identifiable type, you should instead explicitly list the sub-paths that you want to use in the group by.

You can fix you query by simply changing it to:

...
GROUP BY a, app, subject.id