From 8aa8dc2f0b6acd4d8eb88b045f712b688368f08e Mon Sep 17 00:00:00 2001 From: Jan Vales Date: Tue, 27 Mar 2018 22:30:12 +0200 Subject: [PATCH] [1.1.2] inheritance: joined. --- .../src/main/java/dst/ass1/jpa/model/impl/Lecturer.java | 1 + .../src/main/java/dst/ass1/jpa/model/impl/Participant.java | 1 + ass1-jpa/src/main/java/dst/ass1/jpa/model/impl/Person.java | 7 ++++--- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ass1-jpa/src/main/java/dst/ass1/jpa/model/impl/Lecturer.java b/ass1-jpa/src/main/java/dst/ass1/jpa/model/impl/Lecturer.java index 9d7f565..5029598 100644 --- a/ass1-jpa/src/main/java/dst/ass1/jpa/model/impl/Lecturer.java +++ b/ass1-jpa/src/main/java/dst/ass1/jpa/model/impl/Lecturer.java @@ -11,6 +11,7 @@ import java.util.Collection; @Entity @Table(name = Constants.T_LECTURER) +@PrimaryKeyJoinColumn(name = "id") public class Lecturer extends Person implements ILecturer { @OneToMany(targetEntity = Course.class) private Collection courses = new ArrayList<>(); diff --git a/ass1-jpa/src/main/java/dst/ass1/jpa/model/impl/Participant.java b/ass1-jpa/src/main/java/dst/ass1/jpa/model/impl/Participant.java index aad5c5c..4213334 100644 --- a/ass1-jpa/src/main/java/dst/ass1/jpa/model/impl/Participant.java +++ b/ass1-jpa/src/main/java/dst/ass1/jpa/model/impl/Participant.java @@ -11,6 +11,7 @@ import java.util.Collection; @Entity @Table(name = Constants.T_PARTICIPANT, uniqueConstraints = {@UniqueConstraint(columnNames = {Constants.M_PARTICIPANT_ACCOUNT, Constants.M_PARTICIPANT_BANK_CODE})}) +@PrimaryKeyJoinColumn(name = "id") @NamedQuery(name = Constants.Q_PARTICIPANT_BY_EMAIL, query = "SELECT p FROM " + Constants.T_PARTICIPANT + " as p where p." + Constants.M_PERSON_EMAIL + " = :email") public class Participant extends Person implements IParticipant { diff --git a/ass1-jpa/src/main/java/dst/ass1/jpa/model/impl/Person.java b/ass1-jpa/src/main/java/dst/ass1/jpa/model/impl/Person.java index 00e6786..eca46d5 100644 --- a/ass1-jpa/src/main/java/dst/ass1/jpa/model/impl/Person.java +++ b/ass1-jpa/src/main/java/dst/ass1/jpa/model/impl/Person.java @@ -6,14 +6,15 @@ import dst.ass1.jpa.util.Constants; import javax.persistence.*; -@MappedSuperclass +@Entity @Table(name = Constants.T_PERSON) -public class Person implements IPerson { +@Inheritance(strategy = InheritanceType.JOINED) +public abstract class Person implements IPerson { @Id @GeneratedValue private Long id; - @Column + @Column() private String name; @Embedded -- 2.43.0