How to solve EclipseLink Exception: 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 'OPTION SQL_SELECT_LIMIT=DEFAULT' Error Code: 1064

If you use any of the reserved words to name a field, the SQL generated by eclipseLink will have an invalid syntax (Error Code: 1064).

You can try to upgrade your mysql java connector library first. mysql-connector-java-5.1.27-bin.jar is different from mysql-connector-java-5.1.27.jar.  mysql-connector-java-5.1.27-bin.jar is not available from the Maven repository.

Then One solution is to change your field name into something not belongs to the reserved words.

Another solution is according to JPA 2.0 specification:

2.13 Naming of Database Objects

...
To specify delimited identifiers, one of the following approaches must be used:
  • It is possible to specify that all database identifiers in use for a persistence unit be treated as delimited identifiers by specifying the <delimited-identifiers/> element within thepersistence-unit-defaults element of the object/relational xml mapping file. If the<delimited-identifiers/> element is specified, it cannot be overridden.
  • It is possible to specify on a per-name basis that a name for a database object is to be interpreted as a delimited identifier as follows:
    • Using annotations, a name is specified as a delimited identifier by enclosing the name within double quotes, whereby the inner quotes are escaped, e.g.,@Table(name="\"customer\"").
    • When using XML, a name is specified as a delimited identifier by use of double quotes, e.g.,<table name="&quot;customer&quot;"/>

Comments

Popular posts from this blog