Spring Roo
  1. Spring Roo
  2. ROO-1040

Integration tests fail for RooDbManaged Entity with RooEntity(identifierType = String.class)

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Won't Fix
    • Affects Version/s: 1.1.0.M2
    • Fix Version/s: 1.1.0.RC1
    • Component/s: TESTING
    • Labels:
      None

      Description

      Integration test generated from a database reengineered Entity with a primary key of type string currently fail with:

      org.springframework.orm.jpa.JpaSystemException: 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

      Solution: remove

      @GeneratedValue(strategy = GenerationType.AUTO)
      

      from the field annotated with @ID for privileged aspect Whatever_Roo_Entity

      and make sure the primary key is set to something useful before the entity is persisted, e.g

      @Entity
      @RooJavaBean
      @RooToString
      @RooEntity(identifierType = String.class, identifierField = "securityquestionId", identifierColumn = "securityquestion_id")
      @RooDbManaged
      @Table(name = "t_securityquestion")
      public class TSecurityquestion {
      
          @PrePersist
          public void generateSecurityQuestionId() {
      	setSecurityquestionId(java.util.UUID.randomUUID().toString());
          }
      }
      

        Issue Links

          Activity

          Hide
          Alan Stewart added a comment -

          As mentioned before, I can't enforce the GenerationType using DBRE as it is responsibility of EntityMetadata to do this. ROO-384 will enable the GenerationType to be specified on the Roo command line for the entity command.

          Show
          Alan Stewart added a comment - As mentioned before, I can't enforce the GenerationType using DBRE as it is responsibility of EntityMetadata to do this. ROO-384 will enable the GenerationType to be specified on the Roo command line for the entity command.
          Hide
          Mitchell Elutovich added a comment -

          Alan,
          Since ROO-384 has been closed after your comment in Sep 10 are you assuming that the work around there will also work here to a) remove the "@GeneratedValue(strategy = GenerationType.AUTO)" and/or b) to add the @PrePersist.

          Also I'm as of yet unclear how one orders ITDs onto ITDs; perhaps you or Andy or someone else knows how to enforce that Annotator will add Anno onto "id". (That Annotator is applied after Demo.) And how this is done when there is an ITD to an ITD to an ITD.

          Show
          Mitchell Elutovich added a comment - Alan, Since ROO-384 has been closed after your comment in Sep 10 are you assuming that the work around there will also work here to a) remove the "@GeneratedValue(strategy = GenerationType.AUTO)" and/or b) to add the @PrePersist. Also I'm as of yet unclear how one orders ITDs onto ITDs; perhaps you or Andy or someone else knows how to enforce that Annotator will add Anno onto "id". (That Annotator is applied after Demo.) And how this is done when there is an ITD to an ITD to an ITD.
          Hide
          Mitchell Elutovich added a comment -

          I still haven't seen a response to my comment. I am disappointed in the lack of communication between the ROO team and what I thought was just on the forum but seems here also.

          Show
          Mitchell Elutovich added a comment - I still haven't seen a response to my comment. I am disappointed in the lack of communication between the ROO team and what I thought was just on the forum but seems here also.
          Hide
          Alan Stewart added a comment -

          I'm unclear on how I can help here?

          A Roo-annotated java class can have many ITDs depending on what @Roo annotations are present. There is no order to the ITDs as such. The java class and its ITDs form one whole compilation unit.

          Show
          Alan Stewart added a comment - I'm unclear on how I can help here? A Roo-annotated java class can have many ITDs depending on what @Roo annotations are present. There is no order to the ITDs as such. The java class and its ITDs form one whole compilation unit.
          Hide
          Mitchell Elutovich added a comment -

          Thank you for responding.
          In a comment dated Sep 26 2010 you commented that ROO-384 will allow the GenerationType to be specified on the Roo command line for the entity command. However, Since ROO-384 has been closed after your comment are you assuming that the work around there will also work here to a) remove the "@GeneratedValue(strategy = GenerationType.AUTO)" and/or b) to add the @PrePersist. ???? Perhaps another way to phrase it is how will that work around apply in this situation?

          The question about ITD ordering is because the work-around discussed there discusses a ITD annotating something introduced by another ITD, so I'm asking what is needed if anything to make sure that the annotating something introduced by another ITD does have any ordering related necesatities.

          Show
          Mitchell Elutovich added a comment - Thank you for responding. In a comment dated Sep 26 2010 you commented that ROO-384 will allow the GenerationType to be specified on the Roo command line for the entity command. However, Since ROO-384 has been closed after your comment are you assuming that the work around there will also work here to a) remove the "@GeneratedValue(strategy = GenerationType.AUTO)" and/or b) to add the @PrePersist. ???? Perhaps another way to phrase it is how will that work around apply in this situation? The question about ITD ordering is because the work-around discussed there discusses a ITD annotating something introduced by another ITD, so I'm asking what is needed if anything to make sure that the annotating something introduced by another ITD does have any ordering related necesatities.

            People

            • Assignee:
              Alan Stewart
              Reporter:
              An Dams
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: