Spring Roo
  1. Spring Roo
  2. ROO-2424

IdentifierGenerationException creating an entity generated with DBRE

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Blocker Blocker
    • Resolution: Works as Designed
    • Affects Version/s: 1.1.4.RELEASE
    • Fix Version/s: 1.1.4.RELEASE
    • Component/s: PERSISTENCE
    • Environment:
      Linux Ubuntu 10.10, Apache Maven 3.0.2, Java 1.6.0_23, Commit 4e7e817def6094bfc6f8f1b7cc989c9969954651

      Description

      Database properties:

      • User: test
      • Password: test
      • Database: testDB

      Attached database.sql script with structure creation.

      Execute attached log.roo script:

      project --topLevelPackage org.gvnix.test.dbre.acuses
      persistence setup --provider HIBERNATE --database POSTGRES --hostName localhost --password test --userName test --databaseName testDB
      osgi obr url add --url http://spring-roo-repository.springsource.org/repository.xml
      osgi obr start --bundleSymbolicName org.springframework.roo.wrapping.postgresql-jdbc3
      osgi obr url remove --url http://spring-roo-repository.springsource.org/repository.xml
      database reverse engineer --schema public --package ~.domain
      controller all --package ~.web
      

      When you create an entity next exception is raised:

      org.hibernate.id.IdentifierGenerationException: Unknown integral data type for ids : java.lang.String; nested exception is javax.persistence.PersistenceException: org.hibernate.id.IdentifierGenerationException: Unknown integral data type for ids : java.lang.String
      

      Attached stack trace.

      1. database.sql
        0.4 kB
        Mario Martínez Sánchez - gvNIX - DiSiD Technologies S.L.
      2. log.roo
        0.7 kB
        Mario Martínez Sánchez - gvNIX - DiSiD Technologies S.L.
      3. stacktrace.err
        4 kB
        Mario Martínez Sánchez - gvNIX - DiSiD Technologies S.L.

        Issue Links

          Activity

          Hide
          Stefan Schmidt added a comment -

          This appears to be a duplicate of ROO-1040. Please read the comments there for a workaround. Also this is not related to the MVC scaffolding in any way. You can verify that by changing your ORM to EclipseLink where you will see all works just fine. This appears to be a Hibernate specific issue.

          Show
          Stefan Schmidt added a comment - This appears to be a duplicate of ROO-1040 . Please read the comments there for a workaround. Also this is not related to the MVC scaffolding in any way. You can verify that by changing your ORM to EclipseLink where you will see all works just fine. This appears to be a Hibernate specific issue.

          Without

          @GeneratedValue(strategy = GenerationType.AUTO)
          

          The error change:

          org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): org.gvnix.test.dbre.acuses.domain.TcmnProvincias; nested exception is javax.persistence.PersistenceException: org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): org.gvnix.test.dbre.acuses.domain.TcmnProvincias
          

          Error is expected because no generation strategy is defined for a required field because it is the primary key.
          This seems to confirm the problem with the identifiers generation.

          Show
          Mario Martínez Sánchez - gvNIX - DiSiD Technologies S.L. added a comment - Without @GeneratedValue(strategy = GenerationType.AUTO) The error change: org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): org.gvnix.test.dbre.acuses.domain.TcmnProvincias; nested exception is javax.persistence.PersistenceException: org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): org.gvnix.test.dbre.acuses.domain.TcmnProvincias Error is expected because no generation strategy is defined for a required field because it is the primary key. This seems to confirm the problem with the identifiers generation.
          Hide
          Alan Stewart added a comment -

          As Stefan suggested would you please try EclipseLink? Also, if there is something wrong with the generated JPA-annotated code this can be fixed. However, if you are seeing a limitation of DoD and/or Hibernate, then this ticket is not a bug.

          Show
          Alan Stewart added a comment - As Stefan suggested would you please try EclipseLink? Also, if there is something wrong with the generated JPA-annotated code this can be fixed. However, if you are seeing a limitation of DoD and/or Hibernate, then this ticket is not a bug.

          With EclipseLink it works.

          Show
          Mario Martínez Sánchez - gvNIX - DiSiD Technologies S.L. added a comment - With EclipseLink it works.
          Hide
          Alan Stewart added a comment -

          As DBRE has created valid JPA code and it has been tested OK using EclipseLink, the issue appears to be with Hibernate as per ROO-1040

          Show
          Alan Stewart added a comment - As DBRE has created valid JPA code and it has been tested OK using EclipseLink, the issue appears to be with Hibernate as per ROO-1040

            People

            • Assignee:
              Alan Stewart
              Reporter:
              Mario Martínez Sánchez - gvNIX - DiSiD Technologies S.L.
            • Votes:
              2 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 0.75d
                0.75d
                Remaining:
                Remaining Estimate - 0.75d
                0.75d
                Logged:
                Time Spent - Not Specified
                Not Specified