Hi guys. I'm using hibernate 3.2.4.sp1 with Informix 10.
I have an Obj1 that has a many-to-many mapping with a domain Obj2 object and a one-to-one mapping with an object Obj3. Both Obj2 and Obj3 shouldn't be touched when Obj1 gets deleted. Alright...
Having the delete HQL
delete Obj1 obj1 where obj1.obj3.id = :id being executed like the following:
Code:
Query q = session.createQuery( "delete Obj1 obj1 where obj1.obj3.id = :id" );
q.setParameter( "id", id );
return q.executeUpdate();
I receive the exception:
org.hibernate.exception.ConstraintViolationException: could not execute update queryand the following log line:
16:05:50,892 ERROR [JDBCExceptionReporter] Key value for constraint (u135_69) is still being referenced.Looking at the generated SQL, I see that Hibernate is trying to delete the only the records of the main object, leaving behind the many-to-many associative table, like this:
Code:
delete
from
Object1
where
obj3_id=?
When I first execute a selectec and then a delete for each returned instance, everything works. Any idea?
TIA!