version 3.2
Please , i am desperate!!!!!
I have QueryEvent that has one-to-many relation with BusinessRules
(This is not bi-directional)
The Fk is in the BusinessRules to the QueryEvent
i want to run the following sql:
Code:
DELETE FROM business_rules
WHERE EXISTS
(select *
from QUERY_EVENTS
where business_rules.QueryEvent_BusinessRule_Hjid = QUERY_EVENTS.Hjid and QUERY_EVENTS.Hjid = 25);
so i write the following Hql:
Code:
"delete from BusinessRule br where exists(from QueryEvent q where q.BusinessRule = br.Hjid and q.Hjid = 26)"
but hibernate generate the following illegal sql:
Code:
delete from BUSINESS_RULES where exists (select queryevent1_.Hjid from QUERY_EVENTS queryevent1_, BUSINESS_RULES businessru2_ where queryevent1_.Hjid=businessru2_.QueryEvent_BusinessRule_Hjid and .=BUSINESS_RULES.Hjid and queryevent1_.Hjid=26)
the problem is :
the section - and
Code:
.=BUSINESS_RULES.Hjid
.
java.sql.SQLException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=BUSINESS_RULES.Hjid and queryevent1_.Hjid=26)' at line 1
i tried with " exists " but than i got a sql exception that i cant update in a from clause (hibernate write the child again in the exists clause)
please , advice.
please!!!!!!!!
how can i delete a child in hql???? (the best will be if i can delete the child and the parent but i understood that hql dosnt support in cascade , so i get constraits violation)
Thank you