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? 
> 

Reply via email to