0
我有3個表skill_checklist,skill_group,skill_master和映射表skill_checklist_group_masterHibernate映射3個實體一個連接表
該協會是爲
checklist <-- many to many --> Group
Group <-- many to many --> skills
有人能告訴我如何管理這3 hibernate中的表關聯與註釋?
下面是我的表結構
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
)
我沒有用Hibernate經驗,所以編碼的例子一定會幫助我在這裏。使用最新版本的hibernate。
你一直沒有幫助...- 1爲您的答案。我遇到了關聯問題! – coder310
好的..但是,你有你的實體創建?你可以把你的實體代碼? –
如果您需要將實體與其他實體關聯起來。你需要一個JoinColumn註釋..類似這樣 –