Hibernate version: 3.0.5
Are hibernate HQL deletes designed to cascade? I get a foreign key constraint error against a one-to-one mapped property when I attempt to delete an entity. The delete cascades correctly (and fully) if I load the entity and then delete. Is this the intended behavior?
Code:
//fails, fk constraint error on one-to-one mapped property
Session session = currentSession();
Transaction tx = session.beginTransaction();
session.createQuery("delete Foo where Id = '555555'").executeUpdate();
tx.commit();
closeSession();
Code:
//works, cascades to delete one-to-one
Session session = currentSession();
Transaction tx = session.beginTransaction();
Foo f = (Foo) session.load(Foo.class, "555555");
session.delete(f);
tx.commit();
closeSession();