Uploaded image for project: 'Spring Roo'
  1. Spring Roo
  2. ROO-128

Use JSR-303 annotations to feed schema settings to JPA/Hibernate (for table creation)

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.0.0.M2
    • Fix Version/s: 1.0.0.RC1
    • Component/s: PERSISTENCE
    • Labels:
      None
    • Environment:
      Mac OS X

      Description

      Per the thread referenced above, Stefan suggested I create an enhancement JIRA.

      I would like to see roo take the information in the JSR-303 annotations such as

      @NotNull
      @Size(min = 1, max = 40)
      private String conferenceName;

      and then find a way to generate the appropriate field attributes in the target database during JPA and hibernate ddl generation. Is there some way of making JPA boot dependent on startup of the validations engine (so that proper JPA attributes are woven at runtime?) If this can't be done, then it should be noted in the documentation as a temporary limitation until JPA 2.0 perhaps, since it may end up using JSR-303 validations anyway?

      Annotations to consider
      @NotNull & @Nullable - the obvious one
      @Size - max should be the length for a text field, maybe datatype change but not sure what this is up to (JPA?)
      @Digits(integer=4, fraction=2) - should make the field the equivalent of DECIMAL(6,2) - six total, two to right of decimal (or whatever the valid syntax of a database is based on the equivalent JPA @Column setting).
      @DecimalMax - I suppose we could infer the scale and precision numbers from a decimal. Example: @DecimalMax("50000.34") -> 5, 2
      @Max - same as @DecimalMax perhaps

      I'm not sure this can be done without somehow emulating the JPA @NotNull, @Column and other annotations. Until then, you get a false sense that the schema is being generated appropriately, but setting @Size(...) does not do anything to the length of the JPA field (it will be 255 by default on mysql with hibernate for example), @NotNull doesn't manipulate the schema null option, etc...

      I know I mentioned this early on but more as someone who has used the JPA annotations and that led to discussion around the JSR-303 annotations being the ones roo will use.

        Attachments

          Activity

            People

            Assignee:
            sschmidt Stefan Schmidt
            Reporter:
            krimple Ken Rimple
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: