Spring Roo
  1. Spring Roo
  2. ROO-173

Add ability to define field uniqueness constraints

    Details

    • Type: New Feature New Feature
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Complete
    • Affects Version/s: 1.0.0.RC1
    • Fix Version/s: 1.1.0.RC1
    • Component/s: PERSISTENCE
    • Labels:
      None

      Description

      I think it would be a useful feature for Roo to provide a way to define a field, or set of fields, as unique. For example, when adding a new field to a class:

      add field string -fieldName myField -unique ....

      That would then create a database column with a uniqueness constraint? Otherwise I will have to go in and manually add this constraint to all the columns that need it in the db.

      Also, it would be nice to be able to define multiple-column uniqueness constraints such as in MySql:

      UNIQUE KEY 'userId_2' ('userId','customerId')

        Issue Links

          Activity

          Hide
          Eliseo Soto added a comment -

          Currently I have to manually edit my domain classes to add it like this:

          @NotNull
          @Size(min = 1)
          @Column(unique = true)
          private String myProperty;

          Show
          Eliseo Soto added a comment - Currently I have to manually edit my domain classes to add it like this: @NotNull @Size(min = 1) @Column(unique = true) private String myProperty;
          Hide
          Arturo Alfaro added a comment -

          Eliseo,

          @Column(unique = true)

          wont works with roo too!

          Show
          Arturo Alfaro added a comment - Eliseo, @Column(unique = true) wont works with roo too!
          Hide
          Aravind Santhanam added a comment -

          Tried,
          @Table(name = "PERMISSIONS",uniqueConstraints=@UniqueConstraint(columnNames="name"))
          Not working in roo..

          This feature should be provided by roo similar to grails.

          Show
          Aravind Santhanam added a comment - Tried, @Table(name = "PERMISSIONS",uniqueConstraints=@UniqueConstraint(columnNames="name")) Not working in roo.. This feature should be provided by roo similar to grails.
          Hide
          Alan Stewart added a comment -

          --unique option added to "field string" and "field number" commands causing "unique = true" to be added to @Column annotation. Git ID 4b37e7376055f9b32fe80f1e6f66ad023a3f94e4

          Show
          Alan Stewart added a comment - --unique option added to "field string" and "field number" commands causing "unique = true" to be added to @Column annotation. Git ID 4b37e7376055f9b32fe80f1e6f66ad023a3f94e4
          Hide
          not applicable added a comment -

          what about composite/compound unique constraints?

          as per the original question.
          ___
          Also, it would be nice to be able to define multiple-column uniqueness constraints such as in MySql:

          UNIQUE KEY 'userId_2' ('userId','customerId')
          ___

          Is it possible to add the unique flag to the "field set" command?

          Show
          not applicable added a comment - what about composite/compound unique constraints? as per the original question. ___ Also, it would be nice to be able to define multiple-column uniqueness constraints such as in MySql: UNIQUE KEY 'userId_2' ('userId','customerId') ___ Is it possible to add the unique flag to the "field set" command?

            People

            • Assignee:
              Alan Stewart
              Reporter:
              Joe P
            • Votes:
              14 Vote for this issue
              Watchers:
              11 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: