-
Notifications
You must be signed in to change notification settings - Fork 0
Content&report features #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,32 +2,20 @@ | |
|
|
||
| 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", | ||
|
|
@@ -39,7 +27,10 @@ public class Content { | |
| @ManyToOne | ||
| @JoinColumn(name = "user_id") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not needed like JoinTable |
||
| private User user; | ||
|
|
||
|
|
||
| @OneToMany(mappedBy = "content", cascade = CascadeType.REMOVE, orphanRemoval = true) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
|
|
@@ -55,6 +46,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; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to configure JoinTable or JoinColumn, use the defaults unless you are using a legacy database