I have a query. But it does not work. I tested it on Oracle SQL Developer, It worked. So I wrote it in namedquery. The query is below that works fine on Oracle SQL Developer
SELECT q.* FROM TAKE_EXAM_QUESTION q
INNER JOIN TAKE_EXAM e
on q.tk_exam_id = e.tk_exam_id
where e.user_id= :userId;
And I typed above query in Entity class
@NamedQuery(name = "TakeExamQuestionEntity.question", query = "SELECT qs FROM TakeExamQuestionEntity qs INNER JOIN TakeExamEntity ex on qs.tk_exam_id = ex.tk_exam_id where ex.user_id= :userId "),
But it is not working, I do not know why now working please suggest me.
If you generate entity from table, any fields of table will be remove _ and first character after _ will be upper case. Thus, you should write NamedQuery as below example.
If it not work, you should check you entity they are separated to 2 class (entity Primary Key and entity class) or not.
If your entity has generated as 2 class as above example. You should define
the primaryKey will be an object of EmployeePK that has annotation Embeddable.
If you want to use native query you should use @NamedNativeQuery instead of @NamedQuery.
See also: NamedNativeQuery