I got this exception:
unexpected AST node: query
My query is:
SELECT  u.user_id, u.username,u.email,u.phone,u.status,r.rolename 
FROM user_registration u, roles r 
WHERE u.user_id=r.role_id IN (
    select ur.role_id  from roles ur where ur.role_id=u.user_id
)
This query runs in MySQL, but it's not working in my application
Exception is:
SEVERE: Servlet.service() for servlet [spring] in context with path [/jaga] threw exception [Request processing failed; nested exception is org.hibernate.hql.ast.QuerySyntaxException: unexpected AST node: in near line 1, column 196 [SELECT  u.user_id, u.username,u.email,u.phone,u.status,r.rolename FROM com.jagahunt.admin.usermanagement.entity.User u, com.jagahunt.admin.usermanagement.entity.Role r WHERE u.user_id=r.role_id  IN (select ur.role_id  from com.jagahunt.admin.usermanagement.entity.Role ur where ur.role_id=u.user_id)]] with root cause
org.hibernate.hql.ast.QuerySyntaxException: unexpected AST node: in near line 1, column 196 [SELECT  u.user_id, u.username,u.email,u.phone,u.status,r.rolename FROM com.jagahunt.admin.usermanagement.entity.User u, com.jagahunt.admin.usermanagement.entity.Role r WHERE u.user_id=r.role_id  IN (select ur.role_id  from com.jagahunt.admin.usermanagement.entity.Role ur where ur.role_id=u.user_id)]
				
                        
This is a native query that you are trying to execute.
Therefore, you should use
session.createSQLQuery()for this, instead ofsession.createQuery()which takes an HQL entity query instead.