Skip to main content
Jump to: navigation, search

Talk:EclipseLink/Examples/REST/GettingStarted/DatabaseModel

I suggest to change entity Address defined as:

ADDRESSS Table

CREATE TABLE "ADDRESS"

( "ID" NUMBER NOT NULL ENABLE, 
"STREET" VARCHAR2(50), 
"CITY" VARCHAR2(50), 
CONSTRAINT "ADDRESS_PK" PRIMARY KEY ("ID") ENABLE, 
CONSTRAINT "ADDRESS_FK" FOREIGN KEY ("ID")
REFERENCES "CUSTOMER" ("ID") ENABLE
)

/


to

ADDRESSS Table

CREATE TABLE "ADDRESS"

( "ID" NUMBER NOT NULL ENABLE, 
"STREET" VARCHAR2(50), 
"CITY" VARCHAR2(50), 
"CUSTOMER_ID" NUMBER,
CONSTRAINT "ADDRESS_PK" PRIMARY KEY ("ID") ENABLE, 
CONSTRAINT "ADDRESS_FK" FOREIGN KEY ("CUSTOMER_ID")
REFERENCES "CUSTOMER" ("ID") ENABLE
)

/

And change further code as well according this change.

Reason: Eclipse (Luna) doesn't generate model classes properly and this construction causes fail in query. To merge primary and foreign key together is not so much common construction and it not appropriate for many further software. To treat OneToOne relation is much more appropriate on the programming side rather than in DB structure.

Copyright © Eclipse Foundation, Inc. All Rights Reserved.