Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Modification is needed for oneToOneLazy example in chapter 4

 
Himai Minh
Ranch Hand
Posts: 1398
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, In the Employee.java, I think we need to add @JoinColumn to ParkingSpace:


Because the SQL commands are :

CREATE TABLE PARKING_SPACE (ID INTEGER  NOT NULL AUTO_INCREMENT,
                            LOT INTEGER, LOCATION VARCHAR(255), PRIMARY KEY (ID));
CREATE TABLE EMPLOYEE (ID INTEGER  NOT NULL AUTO_INCREMENT,
                       NAME VARCHAR(255), SALARY BIGINT,
                       PARKINGSPACE_ID INTEGER, PRIMARY KEY (ID),
                       CONSTRAINT PSPACE_FK FOREIGN KEY (PARKINGSPACE_ID) REFERENCES PARKING_SPACE(ID));

INSERT INTO PARKING_SPACE (LOT, LOCATION) VALUES (1, 'East Lot');
INSERT INTO PARKING_SPACE (LOT , LOCATION) VALUES (2, 'West Lot');

INSERT INTO EMPLOYEE (NAME, SALARY, PARKINGSPACE_ID) VALUES ('Joan', 59000, 1);
INSERT INTO EMPLOYEE (NAME, SALARY, PARKINGSPACE_ID) VALUES ('John', 59000, 1);

 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!