generator-jhipster: Inserts fails with entities having fields named using MySQL reserved words

Using the sub-generator to create entities with fields that are named using MySQL keywords (e.g.: index, group) creates database columns that use those keywords as its names. Performing insert operations using jhispter´s generated Repository fails with hibernate´s SqlExceptionHelper reporting an SQL Exception. In my case:

org.hibernate.engine.jdbc.spi.SqlExceptionHelper - 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 'group,

Steps to reproduce:

  1. Starting from the example jhipster app that uses a MySQL backend, create a new entity using the yo jhipster:entity subgenerator
  2. Add at least one field to that entity named with a MySQL keyword (e.g.: group)
  3. Lauch the application and go to to the Entities > [entity name] page and click Create a new [entity name]
  4. Fill the form with valid values and click Save.

Result: The operation fails because of an SQL exception. Running the generatad statement in the MySQL terminal fails in the same way unless you surround the offending name with backticks (`).

Using generator-jhipster 2.6.0 package, on Windows 7 MySQL Server version: 5.6.20

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 35 (15 by maintainers)

Commits related to this issue

Most upvoted comments

What about Identity?

Like mentioned before it’s probably a good idea to keep the entity as USER and just rename the table. If the plural form is used, it should be plural for all tables though.

I would also prefer no prefixes; however, creating a reserved word checking for MySQL, PostgreSQL, Mongo, and Cassandra may be somewhat time consuming.

MySQL - http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html PostgreSQL - http://www.postgresql.org/docs/7.3/static/sql-keywords-appendix.html Mongo - http://docs.mongodb.org/manual/reference/command/ , this is closest thing I found to a list Cassandra - https://cassandra.apache.org/doc/cql3/CQL.html

So until it is done please keep the T_.

I don’t like prefix tables, I personally always remove it from my projects with jhipster.