From 60d3dfea2073ee83ffede649ef4049eb257d577d Mon Sep 17 00:00:00 2001 From: alitpc25 Date: Tue, 12 Dec 2023 01:07:56 +0300 Subject: [PATCH] #551 @Lob annotated fields removed, for large strings, used 2048 column length. --- .../resq/src/main/java/com/groupa1/resq/entity/Action.java | 3 +-- .../resq/src/main/java/com/groupa1/resq/entity/Event.java | 4 +--- .../resq/src/main/java/com/groupa1/resq/entity/Feedback.java | 3 +-- .../resq/src/main/java/com/groupa1/resq/entity/Info.java | 3 +-- .../src/main/java/com/groupa1/resq/entity/Notification.java | 3 +-- .../resq/src/main/java/com/groupa1/resq/entity/Task.java | 4 +--- .../resq/src/main/java/com/groupa1/resq/entity/User.java | 3 ++- .../src/main/java/com/groupa1/resq/entity/UserProfile.java | 5 ++--- .../java/com/groupa1/resq/repository/EventRepository.java | 3 ++- 9 files changed, 12 insertions(+), 19 deletions(-) diff --git a/resq/backend/resq/src/main/java/com/groupa1/resq/entity/Action.java b/resq/backend/resq/src/main/java/com/groupa1/resq/entity/Action.java index cdc478ec..6db223a8 100644 --- a/resq/backend/resq/src/main/java/com/groupa1/resq/entity/Action.java +++ b/resq/backend/resq/src/main/java/com/groupa1/resq/entity/Action.java @@ -24,8 +24,7 @@ public class Action extends BaseEntity { @JoinColumn(name = "verifier_id") private User verifier; - @Lob - @Column(length = 3000) + @Column(length = 2048) private String description; private LocalDateTime dueDate; diff --git a/resq/backend/resq/src/main/java/com/groupa1/resq/entity/Event.java b/resq/backend/resq/src/main/java/com/groupa1/resq/entity/Event.java index b4c94437..a16db4a9 100644 --- a/resq/backend/resq/src/main/java/com/groupa1/resq/entity/Event.java +++ b/resq/backend/resq/src/main/java/com/groupa1/resq/entity/Event.java @@ -1,6 +1,5 @@ package com.groupa1.resq.entity; -import com.groupa1.resq.entity.enums.EEventType; import jakarta.persistence.*; import lombok.Data; import lombok.EqualsAndHashCode; @@ -25,8 +24,7 @@ public class Event extends BaseEntity { @JoinColumn(name = "reporter_id") private User reporter; - @Lob - @Column(length = 3000) + @Column(length = 2048) private String description; private LocalDateTime reportDate; diff --git a/resq/backend/resq/src/main/java/com/groupa1/resq/entity/Feedback.java b/resq/backend/resq/src/main/java/com/groupa1/resq/entity/Feedback.java index 292616e5..e8a59c8b 100644 --- a/resq/backend/resq/src/main/java/com/groupa1/resq/entity/Feedback.java +++ b/resq/backend/resq/src/main/java/com/groupa1/resq/entity/Feedback.java @@ -24,7 +24,6 @@ public class Feedback extends BaseEntity { @JoinColumn(name = "creator_id") private User creator; - @Lob - @Column(length = 3000) + @Column(length = 2048) private String message; } diff --git a/resq/backend/resq/src/main/java/com/groupa1/resq/entity/Info.java b/resq/backend/resq/src/main/java/com/groupa1/resq/entity/Info.java index 87e0f417..c1eeaede 100644 --- a/resq/backend/resq/src/main/java/com/groupa1/resq/entity/Info.java +++ b/resq/backend/resq/src/main/java/com/groupa1/resq/entity/Info.java @@ -21,8 +21,7 @@ public class Info extends BaseEntity{ @JoinColumn(name = "user_id") private User user; - @Lob - @Column(length = 3000) + @Column(length = 2048) private String description; private BigDecimal latitude; diff --git a/resq/backend/resq/src/main/java/com/groupa1/resq/entity/Notification.java b/resq/backend/resq/src/main/java/com/groupa1/resq/entity/Notification.java index d31ded24..741df185 100644 --- a/resq/backend/resq/src/main/java/com/groupa1/resq/entity/Notification.java +++ b/resq/backend/resq/src/main/java/com/groupa1/resq/entity/Notification.java @@ -21,8 +21,7 @@ public class Notification extends BaseEntity{ private String title; - @Lob - @Column(length = 1000) + @Column(length = 2048) private String body; private boolean isRead; diff --git a/resq/backend/resq/src/main/java/com/groupa1/resq/entity/Task.java b/resq/backend/resq/src/main/java/com/groupa1/resq/entity/Task.java index b5f7cf3f..3c762b35 100644 --- a/resq/backend/resq/src/main/java/com/groupa1/resq/entity/Task.java +++ b/resq/backend/resq/src/main/java/com/groupa1/resq/entity/Task.java @@ -5,7 +5,6 @@ import jakarta.persistence.*; import lombok.Data; import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; import lombok.ToString; import java.util.HashSet; @@ -41,8 +40,7 @@ public class Task extends BaseEntity { @Enumerated(EnumType.STRING) private EStatus status; - @Lob - @Column(length = 3000) + @Column(length = 2048) private String description; public Task() { diff --git a/resq/backend/resq/src/main/java/com/groupa1/resq/entity/User.java b/resq/backend/resq/src/main/java/com/groupa1/resq/entity/User.java index 5f4294a2..5899c8b6 100644 --- a/resq/backend/resq/src/main/java/com/groupa1/resq/entity/User.java +++ b/resq/backend/resq/src/main/java/com/groupa1/resq/entity/User.java @@ -44,7 +44,8 @@ public class User extends BaseEntity { @Enumerated(EnumType.STRING) private Set roles = new HashSet<>(); - @OneToOne(fetch = FetchType.LAZY, mappedBy = "user") + @OneToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "user_profile_id", referencedColumnName = "id") private UserProfile userProfile; @OneToMany(fetch = FetchType.LAZY, mappedBy="requester") diff --git a/resq/backend/resq/src/main/java/com/groupa1/resq/entity/UserProfile.java b/resq/backend/resq/src/main/java/com/groupa1/resq/entity/UserProfile.java index f25527f4..84c75040 100644 --- a/resq/backend/resq/src/main/java/com/groupa1/resq/entity/UserProfile.java +++ b/resq/backend/resq/src/main/java/com/groupa1/resq/entity/UserProfile.java @@ -14,7 +14,7 @@ @Entity @Table( name = "USER_PROFILE") @Data -@EqualsAndHashCode(exclude = {"user"}) +@EqualsAndHashCode(callSuper = true, exclude = {"user"}) @ToString(exclude = {"user"}) public class UserProfile extends BaseEntity{ @@ -26,8 +26,7 @@ public class UserProfile extends BaseEntity{ @Enumerated(EnumType.STRING) private EGender gender; - @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @JoinColumn(name = "user_id", unique = true) + @OneToOne(mappedBy = "userProfile") private User user; private boolean isEmailConfirmed; diff --git a/resq/backend/resq/src/main/java/com/groupa1/resq/repository/EventRepository.java b/resq/backend/resq/src/main/java/com/groupa1/resq/repository/EventRepository.java index ce07bebb..dca54991 100644 --- a/resq/backend/resq/src/main/java/com/groupa1/resq/repository/EventRepository.java +++ b/resq/backend/resq/src/main/java/com/groupa1/resq/repository/EventRepository.java @@ -2,12 +2,13 @@ import com.groupa1.resq.entity.Event; -import com.groupa1.resq.entity.Need; import com.groupa1.resq.entity.User; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; import java.util.List; +@Repository public interface EventRepository extends JpaRepository { List findByReporter(User reporter);