Sanjay, If you have foreign keys that are not known to OpenJPA (which is more likely when you are mapping to a schema that was not created by the mapping tool), statements may not get ordered correctly. If this is the case, adding this property to your persistence.xml may correct the problem:
<property name="openjpa.jdbc.SchemaFactory" value="native(ForeignKeys=true)"/> This will result in object mapping validation against the database schema, picking up additional foreign key constraints. -Jeremy
