如何在JPA / Hibernate映射中对以下模型进行建模

时间:2015-08-26 13:56:39

标签: java hibernate jpa

如何在JPA / Hibernate映射中模拟以下模型

表SME_ANCHOR的DDL

  CREATE TABLE "IRIS"."SME_ANCHOR" 
   (    "NAME" VARCHAR2(250 CHAR), 
    "REPORT_PKID" VARCHAR2(32 CHAR), 
    "PKID" VARCHAR2(32 CHAR), 
    "INDUSTRY_CODE" VARCHAR2(250 CHAR), 
    "ACTIVE_FLAG" VARCHAR2(50 CHAR), 
    "PORTFOLIO_PKID" VARCHAR2(32 CHAR), 
    "POSTAL_CODE" VARCHAR2(250 CHAR), 
    "CITY" VARCHAR2(250 CHAR)
   ) 
ALTER TABLE "IRIS"."SME_ANCHOR" ADD CONSTRAINT "SAR_PK" PRIMARY KEY ("PKID", "ACTIVE_FLAG")

表LOAN_SME的DDL

  CREATE TABLE "IRIS"."LOAN_SME" 
   (    "SME_ANCHOR_PKID" VARCHAR2(32 CHAR), 
    "LOAN_ANCHOR_PKID" VARCHAR2(32 CHAR), 
    "ACTIVE_FLAG" VARCHAR2(50 CHAR)
   ) 
ALTER TABLE "IRIS"."LOAN_SME" ADD CONSTRAINT "PK_LOAN_SME" PRIMARY KEY ("SME_ANCHOR_PKID", "ACTIVE_FLAG", "LOAN_ANCHOR_PKID")

表LOAN_ANCHOR的DDL

  CREATE TABLE "IRIS"."LOAN_ANCHOR" 
   (    "LOAN_ID_STRD" VARCHAR2(240 CHAR), 
    "PORTFOLIO_PKID" VARCHAR2(32 CHAR), 
    "REPORT_PKID" VARCHAR2(32 CHAR), 
    "STATUS" VARCHAR2(250 CHAR), 
    "CURRENCY" VARCHAR2(250 CHAR), 
    "PURPOSE" VARCHAR2(253 CHAR), 
    "PKID" VARCHAR2(32 CHAR), 
    "ACTIVE_FLAG" VARCHAR2(50 CHAR), 
   )
ALTER TABLE "IRIS"."LOAN_ANCHOR" ADD CONSTRAINT "LAR_PK" PRIMARY KEY ("PKID", "ACTIVE_FLAG")

这里的难点在于模型化具有由2个元素组成的键的实体和由3个元素组成的外键。 我该怎么解决这个问题。 我正在尝试@ManyToMany协会,但没有成功。 任何帮助都会很感激。

0 个答案:

没有答案