title: hibernate mapping 3 entities to one join table
body: <p>I have 3 tables skill_checklist, skill_group, skill_master and a mapping table skill_checklist_group_master</p>
  
  <p>The association is as</p>
  
  <pre><code>checklist &lt;-- many to many --&gt; Group 
  Group &lt;-- many to many --&gt; skills 
  </code></pre>
  
  <p>Can some one tell me how to manage this 3 table association in hibernate with annotations?</p>
  
  <p>Below are my table structures</p>
  
  <pre><code>CREATE TABLE public.skill_checklist
  (
    id bigint NOT NULL DEFAULT nextval('skill_checklist_id_seq'::regclass),
    name character varying(256) NOT NULL,
    description character varying(500) NOT NULL,
    CONSTRAINT "PK_SKILL_CHECKLIST_ID" PRIMARY KEY (id)
  )
  
  CREATE TABLE public.skill_group
  (
    id bigint NOT NULL DEFAULT nextval('skill_group_id_seq'::regclass),
    name character varying(256) NOT NULL,
    description character varying(500) NOT NULL,
    CONSTRAINT "PK_SKILL_GROUP_ID" PRIMARY KEY (id)
  )
  
  CREATE TABLE public.skill_master
  (
    id bigint NOT NULL DEFAULT nextval('skill_master_id_seq'::regclass),
    name character varying(256) NOT NULL,
    description character varying(500) NOT NULL,
    CONSTRAINT "PK_SKILL_MASTER_ID" PRIMARY KEY (id)
  )
  
  CREATE TABLE public.skill_checklist_group_master
  (
    checklist_id bigint NOT NULL,
    group_id bigint NOT NULL,
    skill_id bigint NOT NULL,
    group_order bigint NOT NULL,
    skill_order bigint NOT NULL,
    CONSTRAINT "FK_MAP_CHECKLIST_CHECKLIST_ID" FOREIGN KEY (checklist_id)
        REFERENCES public.skill_checklist (id) MATCH SIMPLE
        ON UPDATE NO ACTION ON DELETE NO ACTION,
    CONSTRAINT "FK_MAP_GROUP_GROUP_ID" FOREIGN KEY (group_id)
        REFERENCES public.skill_group (id) MATCH SIMPLE
        ON UPDATE NO ACTION ON DELETE NO ACTION,
    CONSTRAINT "FK_MAP_SKILL_SKILL_ID" FOREIGN KEY (skill_id)
        REFERENCES public.skill_master (id) MATCH SIMPLE
        ON UPDATE NO ACTION ON DELETE NO ACTION
  )
  </code></pre>
  
  <p>I don't have experience with hibernate so coding examples will definately help me here. Using latest version of hibernate.</p>