Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

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.

Back to the top