Announcement Announcement Module
No announcement yet.
Enforcing field value uniqueness Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Enforcing field value uniqueness

    Is possible to specify a field to be unique? Something like:

    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')

    FYI, using Roo 1.0.0RC1 and Java 6.


  • #2
    If you'd like to add a feature request to Jira, we could look into providing JPA-based uniqueness constraint definition. Realistically Roo's DSL isn't trying to eliminate the requirement for coding (and therefore you can add constraint annotations by hand to your .java files without a problem and they will work), but there may be some value in having uniqueness constraint definition support in Roo given it's such a common use case. I am presently giving some thought to Spring Shell (the part of Roo we'll split out) and how to compose a single command line from multiple add-ons, so uniqueness capabilities might be an interesting goal for this.


    • #3
      Thanks, Ben. I created the feature request in Jira.


      • #4
        What would a such a constraint annotation look like?

        I am just evaluating ROO, but haven't used SPRING before.

        We also need uniqueness constraints, and I'm wondering what you have to do to add these as annotations?