I have a Query "delete from AgentGroup a" . The entity Agentgroup 1:M
relation with agents . When I execute the query above the agents dont get
deleted and I get FK constraint error. Even when i use @PrivateOwned over
the collection of agents
Delete queries only operate on the class you execute it on - so only AgentGroup entities and any subclasses will be deleted. A JPA provider does not read in the objects being deleted in these builk delete/update or native SQL queries, and so cannot determine if there are any references that need to be removed. Any references to these entities will need to be cleaned up before you execute a delete query on AgentGroup; using delete SQL for the refering entities or an update to fix the relationships.
If you want private ownership to be respected or the delete to cascade over mappings, you will need to call remove on the entity instance rather then using a delete query.