openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Curtis <curti...@gmail.com>
Subject Re: Composite foreign keys with MySQL
Date Sat, 02 May 2009 21:44:31 GMT

Here are the known MySQL issues --
http://openjpa.apache.org/builds/latest/docs/manual/manual.html#dbsupport_mysql_issues.

-Rick


Martin Dirichs wrote:
> 
> Hi,
> 
> wondering why OpenJPA's MappingTool refused to add a foreign key
> constraint to the database (error message: openjpa.jdbc.Schema - The
> foreign key "<foreignkey>" was not added to table "[...]"), I discovered
> that composite foreign key support is explicitly disabled for MySQL. These
> are the relevant code lines in
> org.apache.openjpa.jdbc.sql.MySQLDictionary:
> 
>     protected String getForeignKeyConstraintSQL(ForeignKey fk) {
>         // mysql does not support composite foreign keys
>         if (fk.getColumns().length > 1)
>             return null;
>         return super.getForeignKeyConstraintSQL(fk);
>     }
> 
> For all I know, composite foreign keys are possible with MySQL. At least,
> a statement like
> 
> ALTER TABLE detail ADD CONSTRAINT constraint_x FOREIGN KEY (masterId1,
> masterId2) REFERENCES master (masterId1, masterId2);
> 
> works perfectly well. Are there other deficits with MySQL foreign key
> handling I am not aware of or are the above lines in MySQLDictionary.java
> outdated / wrong?
> 
>   Regards,
>     Martin.
> 
> 

-- 
View this message in context: http://n2.nabble.com/Composite-foreign-keys-with-MySQL-tp2772257p2772619.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Mime
View raw message