For testing purposes I made my MySql database case sensitive (to avoid problems when deploying to linux)
The foreign key restrained throws the following exception;
throw new ModelException("The foreignkey "" in table "" references the undefined table "+fk.getForeignTableName());
fk.getForeignTableName is all lower case, while the table name is camel case. hacking the correct camel case into the piece of code that throws the exception 'fixes' the issue. Therefore the issue is that fk.getForeignTableName()) contains the wrong table name.
This wrong table name comes from JdbcModelReader
The PKTABLE_NAME value comes from readColumn what returns the table name in lowercase