Are you using hibernate core or annotations?
I've been able to achieve this with annotations, using the @OnDelete annotation. I'm sure there's an equivalent in hbm mapping files.
However, I did notice the following:
In one-to-many, the @OnDelete was declared on the non-owning side of the relationship (i.e. the parent). For example, in a company-employee relationship, I declared it in company.
In one-to-one, the @OnDelete was declared on the owning side (i.e. the "child" or "inner" entity). For example, in a body-heart relationship, I delcared it in heart.
I was unable to get it declared on foreign keys that associate subclasses and their superclasses in the joined sub class inheritence strategy, so I eventually stopped using hibernate's scheme generation. I only used it to initally get a reasonable schema, and then I continued to maintain it in external scripts (note that even hibernate recommended that auto-generation of schema should not be used in production...)
|