Foreign Key Constraints
The following line does not create foreign keys:
<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
Creates only a schema and deletes the contents of the database.
But if you want to create foreign keys, use the following lines:
<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(foreignKeys=true,schemaAction='dropDB,add')"/> <property name="openjpa.jdbc.SchemaFactory" value="native(foreignKeys=true)" /> <property name="openjpa.jdbc.MappingDefaults" value="ForeignKeyDeleteAction=restrict, JoinForeignKeyDeleteAction=restrict"/>
See generated SQL
In another way, if you want to see SQL output:
<property name="openjpa.Log" value="DefaultLevel=TRACE,SQL=TRACE" />
NOTE To see the generated output in the TomEE console, you need to change the log level in the loggin.properties file using openjpa.level = FINEST
More details at http://openjpa.apache.org/faq.html
Paul vargas
source share