You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by MiƂosz Tylenda <mt...@o2.pl> on 2011/02/24 09:23:13 UTC

RE: Generating SQL including Foreign Key constraints (OpenJpa1.2.2)

Hi,

I don't think you will get foreign key constraints expressed in CREATE TABLE statement out of the box. However, if you have the time and are not afraid of digging into the source, you can try extending the DBDictionary for your database and override a few methods. See getCreateTableSQL(Table table) and getForeignKeyConstraintSQL(ForeignKey fk) methods. Since Table has the getForeignKeys method, that way seems promising. I am referring here to OpenJPA 2.1 source code but 1.2.2 should be similar in this area.

Hope this helps,
Milosz

> 
> Hi,
> 
> Adding: 
> 
>                         <property name="openjpa.jdbc.MappingDefaults" 
>                                 value="ForeignKeyDeleteAction=restrict,
> JoinForeignKeyDeleteAction=restrict" /> 
> 
> Does indeed solve problem 1.
> 
> Thank you.
> 
> Any ideas/suggestions on how to get the generated SQL with the constraint
> expressed in the 
> CREATE table statement and not as a separate ALTER statement? 
> 

RE: Generating SQL including Foreign Key constraints (OpenJpa1.2.2)

Posted by baboune <se...@yahoo.com>.
OK. Good thanks for the help.  I will take a look in the source.
-- 
View this message in context: http://openjpa.208410.n2.nabble.com/Generating-SQL-including-Foreign-Key-constraints-OpenJpa-1-2-2-tp6055639p6061712.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.