I am dumb. I didn't read the documentation carefully. They have mentioned in the documentation that:
MongoDB – Supports JPQL and Criteria queries, with some restrictions: joins, sub-selects, group by and certain database functions are not supported.
I have used FetchType.EAGER, which is making a complex query. I changed it to FetchType.LAZY and it is working now.