I've been able to have JPA/Hibernate to replicate the ON DELETE CASCADE functionality successfully (seems like the default behaviour) but I'm now trying to replicate the ON DELETE SET NULL functionality and I'm facing problems.

do you want to set all the columns of that record to null ? or all the fields of the student entity
–
kommradHomerApr 2 '12 at 14:23

I want the student's teacher column to become null after the student's teacher is deleted from the system.
–
satoshiApr 2 '12 at 15:05

Not that you want to change your schema for JPA, but I'd be curious the effect of changing it to a ManyToMany with cascade deletion on the join table. It should delete the association and leave the student.
–
kevingallagherApr 5 '12 at 14:32

Thank you, both the solutions work perfectly. I personally prefer the second one :)
–
satoshiApr 6 '12 at 17:41

1

The @PreRemove solution is not portable. See JPA spec section 3.5. In general, the lifecycle method of a portable application should not [...] modify relationships within the same persistence context.
–
SpaceTruckerSep 6 '13 at 9:53