Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 8 additions & 22 deletions src/main/java/cat/udl/eps/softarch/demo/domain/Content.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,29 @@

import java.time.ZonedDateTime;

import com.fasterxml.jackson.annotation.JsonIdentityReference;

import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
import lombok.EqualsAndHashCode;

import jakarta.persistence.ManyToOne;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import java.util.List;



@Entity
@Data
//@EqualsAndHashCode(callSuper = true)
public class Content {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long contentId;

/*@ManyToOne
@JsonIdentityReference(alwaysAsId = true)
@Column(nullable = false)
private Project project;*/

@ManyToMany
@JoinTable(
name = "content_tags",
joinColumns = @JoinColumn(name = "content_id"),
inverseJoinColumns = @JoinColumn(name = "tag_id")
)
private List<Tag> tags;

@ManyToOne
@JoinColumn(name = "user_id")
private User user;


@OneToMany(mappedBy = "content", cascade = CascadeType.REMOVE, orphanRemoval = true)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using the OneToMany side, just the ManyToOne. So, in reports, keep track of the Content corresponding to a Report. And for the reverse direction, use a findByContent in the Reports repository

private List<Report> reports;

@NotBlank(message = "Name cannot be empty")
@Column(unique = true, nullable = false)
private String name;
Expand All @@ -55,6 +40,7 @@ public class Content {

private ZonedDateTime modifiedAt;

@Enumerated(EnumType.STRING)
@Column(nullable = false) private Visibility visibility;
}
@Enumerated(EnumType.STRING)
@Column(nullable = false)
private Visibility visibility;
}