We use hibernate to do ORM mapping for mysql. Recently we set up an AWS Aurora database and chose the latest version, which corresponds to MySQL 8.0.34. We had been working with the 8.0.33 version without problems. We began seeing an error in production:
|2024:04:28:15:37:03:110|DEBUG|http-nio-cp-10.3.1.220-8970-exec-9|org.hibernate.util.JDBCExceptionReporter|logExceptions|could
not insert: [com.nxlight.framework.navigator.dao.Role] [insert into
NXC_ROLES (txId, profileId, role, email, status, folder,
enterprise, active, accept, personal, modifiedDate, deleteDate,
groupAccessOnly, ssoId, accessDate) values (?, ?, ?, ?, ?, ?, ?, ?,
?, ?, ?, ?, ?, ?, ?)]
java.sql.SQLSyntaxErrorException: 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 ‘accept, personal,
modifiedDate, deleteDate, groupAccessOnly, ssoId, accessDate) ‘ at
line 1
Upon investigation we narrowed the problem down to the column named “accept”. Fortunately we were able to work around the problem using this in the hibernate config file for this pojo:
<property name="accept"> <column name="[accept]" /> </property>
My question is: Why would that column name have problems. I understand the concept of certain key words must be reserved such as “select”. But why “accept” and why now?
We tried:
- Updating the AWS JDBC driver (no luck).
- Considered downgrading the database but decided against it.
- Changed a few other properties in the hibernate config.
Finally we stumbled upon a solution as indicated above where you can put brackets around the column declaration in the hibernate file and it will force back-tics on the resulting SQL.