1 Reply Latest reply on Jan 26, 2009 9:39 AM by tony.herstell1

    ManyToMany Problem

    tony.herstell1

      given Event as



          @ManyToMany(cascade={CascadeType.ALL})
          private List<User> judges;
          @ManyToMany(cascade={CascadeType.ALL})
          private List<User> scorers;
          @ManyToMany(cascade={CascadeType.ALL})
          private List<User> helpers;
          @ManyToMany(cascade={CascadeType.ALL})
          private List<User> secretaries;
          @ManyToMany(cascade={CascadeType.ALL})
          private List<User> technicalDelegates;
      




      I get a single link table automagically created to User


      The automagically created table, event-user, has a heap of rows (one for judges, one for scorers etc.)


      e.g.
      Event-id
      judges-id
      scoreres-id
      etc.


      I though this was efficient till I saw that each column is set to NOT accept nulls.


      So I cannot add a single judge!


      Can't you add multiple links to another single table?


      DO I have to create a whole new class to link through to User that has a kind of link (Enum) being one of Judge, Scorer etc.



        • 1. Re: ManyToMany Problem
          tony.herstell1

              @JoinTable(name="event_judges")
              @ManyToMany(cascade={CascadeType.ALL})
              private List<User> judges;
              @JoinTable(name="event_scorers")
              @ManyToMany(cascade={CascadeType.ALL})
              private List<User> scorers;
              @JoinTable(name="event_helpers")
              @ManyToMany(cascade={CascadeType.ALL})
              private List<User> helpers;




          This is a workaround... but I had to eliminate the Embedded List User as this still caused a problem as you cant have two with the same JoinTable name