7 Replies Latest reply on May 12, 2010 3:39 PM by jmiettin

    How to validate for uniqueness constraint consisting of multiple columns?


      In my software, I have Foo that has multiple children of type Bar. Each bar should be unique in the sense that for each Foo, there is only one Bar with a given name. This is easily accomplished through Table-annotation:

              name = "bars",
              uniqueConstraints = @UniqueConstraint(columnNames = { "name", "foo_id" })

      Is this constraint somehow validatable through Seam? Currently I have to do manual validation or face an error when I create a new Bar under selected Foo. My understanding is that a single

      @Column(unique = true)

      annotation could be used with s:validate to validate that single constraint. How should I do this more complex validation without repeating the validation logic in business logic (and perhaps using stale data)?