task/3382: Harmonisera tabellnamn #6
|
@ -16,12 +16,14 @@ public class Comment extends DomainObject {
|
|||
private Long id;
|
||||
|
||||
@ManyToOne(optional = false)
|
||||
@JoinColumn(name = "user_id")
|
||||
tozh4728 marked this conversation as resolved
Outdated
|
||||
private User creator;
|
||||
|
||||
@Lob
|
||||
private String comment;
|
||||
|
||||
@ManyToOne(optional = false)
|
||||
@JoinColumn(name = "comment_thread_id")
|
||||
private CommentThread commentThread;
|
||||
|
||||
protected Comment() {
|
||||
|
|
|
@ -8,7 +8,9 @@ import java.util.Set;
|
|||
import java.util.TreeSet;
|
||||
|
||||
@Entity
|
||||
@Table(name = "comment_thread", uniqueConstraints = {@UniqueConstraint(columnNames = {"commentableKey", "commentableId"})})
|
||||
@Table(name = "comment_thread",
|
||||
uniqueConstraints = {@UniqueConstraint(name = "uk_comment_thread_id_key",
|
||||
columnNames = {"commentable_key", "commentable_id"})})
|
||||
@Cacheable(true)
|
||||
public class CommentThread extends DomainObject {
|
||||
|
||||
|
@ -16,11 +18,10 @@ public class CommentThread extends DomainObject {
|
|||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Basic(optional = false)
|
||||
@Column(length = 191)
|
||||
@Column(name = "commentable_key", length = 191, nullable = false)
|
||||
private String commentableKey;
|
||||
|
||||
@Basic(optional = false)
|
||||
@Column(name = "commentable_id", nullable = false)
|
||||
private Long commentableId;
|
||||
|
||||
@OneToMany(mappedBy = "commentThread", orphanRemoval = true, cascade = CascadeType.ALL, targetEntity = Comment.class)
|
||||
|
|
Loading…
Reference in New Issue
Block a user
The renaming of some user foreign key columns seem a bit weird. In some places it was a loss of information by going to just
user_id
while others they got_user_id
appended to them and some were left as-is. Out of the three options justuser_id
is the worst one when there is additional context to be had. In this case "creator", so I think the column should becreator_id
orcreator_user_id
to convey as much information as possible. It is also consistent with other foreign keys that use the<context>_user_id
naming scheme. See for examplecore/src/main/java/se/su/dsv/scipro/peer/PeerRequest.java
and itsrequester_user_id
.