4 Replies Latest reply on Jun 7, 2017 4:59 AM by N L

    Can't use class name "Group" for an entity

    N L Newbie

      If I have this entity:

       

      @Entity
      public class Group {
      
        long id;
      
        @Id
        public long getId() {
        return id;
        }
      
      
        public void setId(long id) {
        this.id = id;
        }
      }
      

       

      I get this error on stratup:

       

      ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 58) MSC000001: Failed to start service jboss.persistenceunit."Test.war#prod": org.jboss.msc.service.StartException in service jboss.persistenceunit."Test.war#prod": javax.persistence.PersistenceException: Unable to execute JPA schema generation create command [create table Group (id bigint not null, primary key (id))]

        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:179)

        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:121)

        at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:667)

        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:193)

        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

        at java.lang.Thread.run(Thread.java:745)

        at org.jboss.threads.JBossThread.run(JBossThread.java:320)

      Caused by: javax.persistence.PersistenceException: Unable to execute JPA schema generation create command [create table Group (id bigint not null, primary key (id))]

        at org.hibernate.jpa.internal.schemagen.GenerationTargetToDatabase.acceptCreateCommands(GenerationTargetToDatabase.java:47)

        at org.hibernate.jpa.internal.schemagen.JpaSchemaGenerator.doGeneration(JpaSchemaGenerator.java:496)

        at org.hibernate.jpa.internal.schemagen.JpaSchemaGenerator.access$300(JpaSchemaGenerator.java:55)

        at org.hibernate.jpa.internal.schemagen.JpaSchemaGenerator$GenerationProcess.execute(JpaSchemaGenerator.java:171)

        at org.hibernate.jpa.internal.schemagen.JpaSchemaGenerator.performGeneration(JpaSchemaGenerator.java:65)

        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:885)

        at org.jboss.as.jpa.hibernate5.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java:44)

        at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:161)

        ... 7 more

      Caused by: org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement "CREATE TABLE GROUP[*] (ID BIGINT NOT NULL, PRIMARY KEY (ID)) "; expected "identifier"; SQL statement:

      create table Group (id bigint not null, primary key (id)) [42001-173]

        at org.h2.message.DbException.getJdbcSQLException(DbException.java:331)

        at org.h2.message.DbException.get(DbException.java:171)

        at org.h2.message.DbException.getSyntaxError(DbException.java:196)

        at org.h2.command.Parser.readIdentifierWithSchema(Parser.java:2805)

        at org.h2.command.Parser.readIdentifierWithSchema(Parser.java:2833)

        at org.h2.command.Parser.parseCreateTable(Parser.java:5295)

        at org.h2.command.Parser.parseCreate(Parser.java:3873)

        at org.h2.command.Parser.parsePrepared(Parser.java:324)

        at org.h2.command.Parser.parse(Parser.java:279)

        at org.h2.command.Parser.parse(Parser.java:251)

        at org.h2.command.Parser.prepareCommand(Parser.java:218)

        at org.h2.engine.Session.prepareLocal(Session.java:428)

        at org.h2.engine.Session.prepareCommand(Session.java:377)

        at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1138)

        at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:168)

        at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:156)

        at org.jboss.jca.adapters.jdbc.WrappedStatement.execute(WrappedStatement.java:198)

        at org.hibernate.jpa.internal.schemagen.GenerationTargetToDatabase.acceptCreateCommands(GenerationTargetToDatabase.java:44)

        ... 14 more

      If I change the class name from Group to something else like Groupe the error disappears. Seems like a bug to me, is that so?