Documenting this here because I just wasted an hour trying to figure this out.
I have an entity Foo with:
@ManyToOne(optional = false)
@JoinColumn(name = "barId")
private Bar bar;
Why does Hibernate not create a foreign key constraint on foo.bar -> bar.id ?
It’s because MySQL does not support foreign key constraints on tables created with ENGINE=MyISAM. You need to create (both!) tables with ENGINE=InnoDB. You can do so by tweaking
my.cnf, and adding a default, or by using a special variable in your JDBC URL: