Reputation: 3037
In my entity class I have a column defined like this:
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="foo_id", nullable=true, updatable=true, foreignKey=@ForeignKey(name="fk_foo_fee"))
private Foo foo;
Today I checked the properties of the foreign key fk_foo_fee
on pgAdmin and found out that its action is on delete no action
. The problem is that the action must be on delete set null
. pgAdmin doesn't let me change it with its interface. So how can I change it with JPA?
Upvotes: 0
Views: 397
Reputation: 773
You can try this:
child.setParent(null);
session.delete(parent);
You should also be able to put it in a PreRemove:
@PreRemove
private void preRemove() {
// set foo to null here
}
Upvotes: 1