I am trying to disable a foreign key constraint generated in my bidirectional association. I was able to do this for all my unidirectional associations, but for some reason it doesn't work here.
I know about the error with ContraintMode.NO_CONSTRAINT, which was recently fixed in Hibernate 5.x, and I am running the latest version of Hibernate 5.2.6.
My annotations now look like this:
class Parent {
@OneToMany(mappedBy="parent", cascade=CascadeType.ALL, orphanRemoval=true)
@OrderColumn(name="childIndex")
public List<Child> getChildren() {
return children;
}
}
class Child {
@ManyToOne(optional=false)
@JoinColumn(name="parent", foreignKey = @ForeignKey(value = ConstraintMode.NO_CONSTRAINT))
public Parent getParent() {
return parent;
}
}
But despite NO_CONSTRAINT, Hibernate still creates a foreign key constraint for child.parent -> parent.id.
Is there anything extra I need to do to suppress a foreign key for a bidirectional case?
Thank!