Using cascade = CascadeType.REMOVE hibernate does not add ‘ON DELETE CASCADE’ during table generation. Is this the right behavior? No problem if I perform em.remove() on parent object but an error raises when I try to execute bulk deletion via HQL.
PostgreSQL 9.1, Hibernate 4.0.0.CR7
What you are looking for is the
@OnDeleteannotation which affects schema generation by hibernate (DDL statements). This annotation does however not cascade deletes to referencing entities/rows in case of bulk delete when there is noON DELETE CASCADEclause in the foreign key definition in the database.