I am trying to fetch profile menus of a profile using jpql with JPA. My 'Profile' and 'ProfileMenus' entities have many to one relationship.
I have tried looking into these answers but couldn't find any working solution.
How to add non-standardized sql functions in Spring Boot application?
Registering a SQL function with JPA and Hibernate
https://vladmihalcea.com/hibernate-sql-function-jpql-criteria-api-query/
I also went through this link and seems to have same problem as mine, How to register non-standarized SQL functions manually in Spring Boot application?
When using native query I can fetch my data using the query below:
SELECT
GROUP_CONCAT(pm.user_menu_id SEPARATOR ',')
AS profile_menu_ids,
p.description
FROM profile p
LEFT JOIN profile_menu pm ON p.id = pm.profile_id
WHERE
p.id =:profileId
AND
pm.status = 'Y'
GROUP BY p.id
The above query provides me data as,
profile_menu_ids | description |
---|---|
4,5 | admin profile |
Is there any way or alternatives in jpql with JPA to obtain result as above?