Skip to content
Advertisement

SQL code does not work when converted to JPQL code (ORA-00904 error code)

Thank you very much for looking at this post :). I have the following problem: I have a piece of SQL code that runs perfectly on the Oracle database. The problem comes when I try to run as JPQL code. I get the following error in the Eclipse IDE:

Internal Exception: java.sql.SQLSyntaxErrorException: ORA-00904: “THIRDTABLE”.”NAME”: invalid identifier.

The SQL that works is the following:

This is the JPQL code that doesn’t work:

I guess the problem comes from this part of the code:

Are multiple expressions in subqueries not supported in JPQL? Is it the pair after the ‘where’ statement ? When I try with only one expression (with l1.oid for example), it works but the result is not the expected one. Also if I remove the code above, it works, but again, it’s not the result I want.

Thanks in advance for the help! 🙂

Advertisement

Answer

I solved the problem by running the SQL code with the createNativeQuery method from the entityManager. It seems that JPQL doesn’t really like pairs in the where statement. Maybe the JPA version I use does not support pairs (I use JPA 2.6.4). This is the code :

Thanks again Abenamor for the solution :).

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement