title: After migration from Hibernate to EclipeLink getting many SQL Exceptions
body: <p>After migration JPA project from Hibernate I'm getting many such exceptions: </p>
  
  <pre><code>    Aug 31, 2015 4:00:52 PM org.eclipse.persistence.session.file:/var/folders/ls/0vdttqm92zq1rtcsjntc4mxw0000gn/T/gfembed8285464623855636118tmp/applications/salonea-1.0/WEB-INF/classes/_LocalServicesMySQL_JTA
  WARNING: 
  Local Exception Stack: 
  Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException
  Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') REFERENCES  ()' at line 1
  Error Code: 1064
  Call: ALTER TABLE provider ADD CONSTRAINT fk_provider_corporation FOREIGN KEY () REFERENCES  ()
  Query: DataModifyQuery(sql="ALTER TABLE provider ADD CONSTRAINT fk_provider_corporation FOREIGN KEY () REFERENCES  ()")
      at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:331)
      at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:900)
      at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeNoSelect(DatabaseAccessor.java:962)
      at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:631)
      at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:558)
      at org.eclipse.persistence.internal.sessions.AbstractSession.basicExecuteCall(AbstractSession.java:2002)
      at org.eclipse.persistence.sessions.server.ServerSession.executeCall(ServerSession.java:570)
      at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:242)
      at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:228)
      at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeNoSelectCall(DatasourceCallQueryMechanism.java:271)
      at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeNoSelect(DatasourceCallQueryMechanism.java:251)
      at org.eclipse.persistence.queries.DataModifyQuery.executeDatabaseQuery(DataModifyQuery.java:85)
      at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:899)
      at org.eclipse.persistence.internal.sessions.AbstractSession.internalExecuteQuery(AbstractSession.java:3214)
      at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1804)
      at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1786)
      at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1737)
      at org.eclipse.persistence.internal.sessions.AbstractSession.priviledgedExecuteNonSelectingCall(AbstractSession.java:5008)
      at org.eclipse.persistence.tools.schemaframework.TableDefinition.createForeignConstraintsOnDatabase(TableDefinition.java:891)
      at org.eclipse.persistence.tools.schemaframework.SchemaManager.createForeignConstraints(SchemaManager.java:194)
  </code></pre>
  
  <p>They seem to be related to foreign key constraints created for @OneToMany, @ManyToMany, etc association. 
  There are also JUnit tests that now don't pass related to bulk deletion (DELETE FROM) of entities associated in such ManyToMany. In hibernate this test have been passing well, and in EclipseLink there is some error.</p>
  
  <p>I don't know whether below errors foreign key constraints may influence this situation? 
  If EclipseLink has totally different implementation and this is so hard to port app from Hibernate (code working in Hibernate can don't work in EclipseLink) </p>
  
  <p>Now I see that in Hibernate there are also similar errors:</p>
  
  <pre><code>HHH000389: Unsuccessful: alter table natural_person drop foreign key FK_xebs35hpmkrexufr4i267ak1
  Table "NATURAL_PERSON" not found; SQL statement:
      alter table natural_person 
          drop 
          foreign key FK_xebs35hpmkrexufr4i267ak1 [42102-173]
  &lt;/event&gt;&lt;/ijLog&gt;
  ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] HHH000389: Unsuccessful: alter table natural_person drop foreign key FK_xebs35hpmkrexufr4i267ak1
  ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] Table "NATURAL_PERSON" not found; SQL statement:
      alter table natural_person 
          drop 
          foreign key FK_xebs35hpmkrexufr4i267ak1 [42102-173]
  HHH000389: Unsuccessful: alter table photo_tagged_with drop foreign key FK_gcjvuf4mauiptth529s2e4gjw
  HHH000389: Unsuccessful: alter table provider drop foreign key fk_provider_corporation
  Table 'salonea.provider' doesn't exist
  Table "PHOTO_TAGGED_WITH" not found; SQL statement:
      alter table photo_tagged_with 
          drop 
          foreign key FK_gcjvuf4mauiptth529s2e4gjw [42102-173]
  </code></pre>