diff --git a/src/main/java/com/LabWork/app/MangaStore/model/Default/Creator.java b/src/main/java/com/LabWork/app/MangaStore/model/Default/Creator.java index d4b5618..0ae6ea6 100644 --- a/src/main/java/com/LabWork/app/MangaStore/model/Default/Creator.java +++ b/src/main/java/com/LabWork/app/MangaStore/model/Default/Creator.java @@ -1,5 +1,7 @@ package com.LabWork.app.MangaStore.model.Default; +import com.LabWork.app.MangaStore.user.model.User; + import javax.persistence.*; import javax.validation.constraints.NotBlank; @@ -10,16 +12,11 @@ import java.util.Objects; @Entity public class Creator { @Id - @GeneratedValue(strategy = GenerationType.AUTO) private Long id; - @NotBlank(message = "creatorName can't be null or empty") - @Column - private String creatorName; - - @NotBlank(message = "hashedPassword can't be null or empty") - @Column - private String hashedPassword; + @OneToOne(fetch = FetchType.LAZY) + @MapsId + private User user; @OneToMany(fetch = FetchType.EAGER, mappedBy = "creator", cascade = CascadeType.REMOVE) private List mangas; @@ -28,8 +25,7 @@ public class Creator { } public Creator(String creatorName, String hashedPassword) { - this.creatorName = creatorName; - this.hashedPassword = hashedPassword; + this.user = user; this.mangas = new ArrayList<>(); } @@ -41,25 +37,11 @@ public class Creator { return mangas; } - public String getCreatorName() { - return creatorName; - } - - public String getHashedPassword() { - return hashedPassword; - } - public void setMangas(List mangas) { this.mangas = mangas; } - public void setCreatorName(String creatorName) { - this.creatorName = creatorName; - } - - public void setHashedPassword(String hashedPassword) { - this.hashedPassword = hashedPassword; - } + public User getUser() { return user; } @Override public boolean equals(Object o) {