3 Replies Latest reply on Feb 16, 2007 5:24 AM by fhh

    Using a JoinTable, getting unique constraint violtions

    None None Master

      Let's say I'm making an accounting system. I have Invoices, and on Invoices I have Products. Every invoice can have a set of one or more products, and there could be duplicates. Every product could show up on any number of invoices. The relationship is uni-directional. The Product doesn't need to have a collection of Invoices that contain it.

      How do I map this?

      It seems like what I need is a JoinTable specification, but when I create it, I get a table with a unique constraint on invoice_id. That should not be the case; I should be able to use that invoice_id multiple times to be able to specify a set of products.

      What I need is a join table that would look like this:

      invoice_id product_id
      33 58
      33 37
      33 962

      but it's failing on the uniqueness constraint of invoice_id. Any ideas on how to specify this?