Hi,
I have a question which I can't find the answer to.
I have two tables. A and B
A is the parent and can have a B.
B is not aware of which A has it.
I have set up so that everything works the way I want except for one thing. I want to be able to delete a B and when I do that, the reference in A should be set to null.
In other words:
a (a1) has a b (b1)
I delete b1
a1 has no b1, the field b is set to null for a1.
It's very easy to do this in MySQL Query browser. Just set the foreign key in table A to (on delete set null).
But is there a way that hibernate can generate the schema automatically?
I'm using the following xml for the reference in table A.
Code:
<many-to-one name="b" column="b_id" class="B" cascade="none" fetch="join" not-null="false" lazy="false"/>
And this generates a foreign key reference in table A, which I want to include a "ON DELETE SET NULL".
Hope that my example describes what I want to do.