Announcement Announcement Module
Collapse
No announcement yet.
Unique key constraint for 2 fields Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Unique key constraint for 2 fields

    Hi,

    In Spring Roo is there a way to add a unique key constraint on an entity for 2 fields?

    My Inventory entity has the following fields:

    Code:
    public class Inventory {
    
        private int quantityOnHand;
    
        @ManyToOne
        private Warehouse warehouse;
    
        @NotNull
        private String sku;
    }
    How do I add a constraint that sku and warehouse make a unique constraint?

  • #2
    Just annotate Inventory with @UniqueConstraint

    http://docs.oracle.com/javaee/6/api/...onstraint.html

    Comment


    • #3
      Thank you! I can't believe I couldn't find that.

      Is there a way to define that in the roo command line or is the only way to modify the entity directly?

      Comment


      • #4
        You could write an addon or extend the existing one

        Comment

        Working...
        X