diff --git a/backend/src/main/java/gov/cdc/ReportVision/models/ApiUser.java b/backend/src/main/java/gov/cdc/ReportVision/models/ApiUser.java index 682ba914..8e164cf1 100644 --- a/backend/src/main/java/gov/cdc/ReportVision/models/ApiUser.java +++ b/backend/src/main/java/gov/cdc/ReportVision/models/ApiUser.java @@ -1,27 +1,28 @@ package gov.cdc.ReportVision.models; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.Id; import jakarta.persistence.ManyToOne; -import lombok.Getter; - import java.util.UUID; +import lombok.Getter; @Getter @Entity public class ApiUser extends BaseEntity { - @Id - @GeneratedValue(generator = "UUID4") - @Column(updatable = false, nullable = false) - private UUID id; + @Id + @GeneratedValue(generator = "UUID4") + @Column(updatable = false, nullable = false) + private UUID id; + + @JsonProperty private String name; + @JsonProperty private String email; - private String name; - private String email; - private String password; // Should be hashed and salted + @JsonIgnore private String password; // Should be hashed and salted - @ManyToOne - private Organization organization; -} \ No newline at end of file + @ManyToOne private Organization organization; +} diff --git a/backend/src/main/java/gov/cdc/ReportVision/models/BaseEntity.java b/backend/src/main/java/gov/cdc/ReportVision/models/BaseEntity.java index 42f90cd5..62160af9 100644 --- a/backend/src/main/java/gov/cdc/ReportVision/models/BaseEntity.java +++ b/backend/src/main/java/gov/cdc/ReportVision/models/BaseEntity.java @@ -7,6 +7,8 @@ import jakarta.persistence.Temporal; import jakarta.persistence.TemporalType; import java.util.Date; +import org.hibernate.annotations.Fetch; +import org.hibernate.annotations.FetchMode; import org.springframework.data.annotation.CreatedDate; import org.springframework.data.annotation.LastModifiedDate; @@ -24,7 +26,13 @@ public abstract class BaseEntity { @LastModifiedDate private Date updatedAt; - @ManyToOne private ApiUser createdBy; + @JsonProperty + @Fetch(FetchMode.JOIN) + @ManyToOne + private ApiUser createdBy; - @ManyToOne private ApiUser updatedBy; + @JsonProperty + @Fetch(FetchMode.JOIN) + @ManyToOne + private ApiUser updatedBy; } diff --git a/backend/src/main/java/gov/cdc/ReportVision/models/Template.java b/backend/src/main/java/gov/cdc/ReportVision/models/Template.java index cf36dd7f..e70597e4 100644 --- a/backend/src/main/java/gov/cdc/ReportVision/models/Template.java +++ b/backend/src/main/java/gov/cdc/ReportVision/models/Template.java @@ -9,6 +9,8 @@ import java.util.UUID; import lombok.Builder; import lombok.Getter; +import org.hibernate.annotations.Fetch; +import org.hibernate.annotations.FetchMode; @Entity @Getter @@ -32,13 +34,16 @@ public class Template extends BaseEntity { private String labName; @OneToMany(mappedBy = "template") + @Fetch(FetchMode.JOIN) private List pages; @Enumerated(EnumType.STRING) @Builder.Default private TemplateStatus status = TemplateStatus.IN_PROGRESS; - @ManyToOne private Organization organization; + @Fetch(FetchMode.JOIN) + @ManyToOne + private Organization organization; public Template( UUID id,