Skip to Content
0
Former Member
May 29, 2008 at 11:30 AM

JPA: "Member Of" Expression - OpenSQLException

15 Views

Hi,

I'm trying to use two "Member Of" expressions for a predicate, as in the following query:

SELECT si FROM SubIn si WHERE (:topicA MEMBER si.topics) OR (:topicB MEMBER si.topics)

The single items (topicA, topicB) which should be tested for membership in a collection are passed as parameters to the query and are proper entities. However, it seems that the constructed query contains syntax errors; I attached the "formatted" error message below. Please let me know if my formatting of the message is distracting and I can attach the plain message. Any hints as to why the final query is not well-formed would be greatly appreciated.

Cheers,

Felix

Caused by: com.sap.sql.log.OpenSQLException: The SQL statement 

"SELECT ... 
WHERE ((?) IN 
(SELECT "A_1"."ID" FROM "TOPICS" "A_1", "J_SI_T" "A_2" WHERE "A_1"."ID" = "A_2"."T_ID" AND "SI"."ID" = "A_2"."SI_ID") 
OR (?) IN 
(SELECT "A_3"."ID" FROM "TOPICS" "A_3", "J_SI_T" "A_4" WHERE "A_3"."ID" = "A_4"."T_ID" AND "SI"."ID" = "A_4"."SI_ID"))" 

contains the syntax error[s]: 
- 1:251 - the IN predicate 
? IN (SELECT "A_1"."ID" FROM "TOPICS" "A_1", "J_SI_T" "A_2" WHERE "A_1"."ID" = "A_2"."T_ID" AND "SI"."ID" = "A_2"."SI_ID")
contains a host variable (parameter marker) as the test value.

- 1:419 - the IN predicate 
? IN (SELECT "A_3"."ID" FROM "TOPICS" "A_3", "J_SI_T" "A_4" WHERE "A_3"."ID" = "A_4"."T_ID" AND "SI"."ID" = "A_4"."SI_ID")
contains a host variable (parameter marker) as the test value.