task/3382: Harmonisera tabellnamn #6

Merged
ansv7779 merged 104 commits from task/3382 into develop 2024-11-12 13:33:44 +01:00
2 changed files with 53 additions and 27 deletions
Showing only changes of commit 4fde7fdac9 - Show all commits

View File

@ -2,6 +2,7 @@ package se.su.dsv.scipro.checklist;
import java.util.Objects;
import jakarta.persistence.Basic;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
@ -20,22 +21,34 @@ import se.su.dsv.scipro.system.User;
@Entity
@Table(name = "checklist_answer")
public class ChecklistAnswer extends DomainObject {
// ----------------------------------------------------------------------------------
// Basic JPA-mappings
// ----------------------------------------------------------------------------------
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Enumerated(EnumType.STRING)
@Basic
@Column(name = "answer", nullable = false)
@Enumerated(EnumType.STRING)
private ChecklistAnswerEnum answer;
@ManyToOne(optional = false)
@JoinColumn(name = "user_id")
private User user;
@Basic
@Column(name = "comment")
@Lob
@Column
private String comment;
// ----------------------------------------------------------------------------------
// JPA-mappings of foreign keys in this table (checklist_answer) referencing other
// tables.
// ----------------------------------------------------------------------------------
@ManyToOne(optional = false)
@JoinColumn(name = "user_id", referencedColumnName = "id")
private User user;
// ----------------------------------------------------------------------------------
// Constructors
// ----------------------------------------------------------------------------------
protected ChecklistAnswer() {
}
@ -48,44 +61,45 @@ public class ChecklistAnswer extends DomainObject {
this.answer = answer != null ? answer : ChecklistAnswerEnum.NO_ANSWER;
}
// ----------------------------------------------------------------------------------
// Properties (Getters and Setters)
// ----------------------------------------------------------------------------------
@Override
public Long getId() {
return this.id;
}
public ChecklistAnswerEnum getAnswer() {
return this.answer;
}
public User getUser() {
return this.user;
}
public String getComment() {
return this.comment;
}
public void setId(Long id) {
this.id = id;
}
public ChecklistAnswerEnum getAnswer() {
return this.answer;
}
public void setAnswer(ChecklistAnswerEnum answer) {
this.answer = answer;
}
public void setUser(User user) {
this.user = user;
public String getComment() {
return this.comment;
}
public void setComment(String comment) {
this.comment = comment;
}
@Override
public String toString() {
return "ChecklistAnswer(id=" + this.getId() + ", answer=" + this.getAnswer() + ", user=" + this.getUser() + ", comment=" + this.getComment() + ")";
public User getUser() {
return this.user;
}
public void setUser(User user) {
this.user = user;
}
// ----------------------------------------------------------------------------------
// Methods Common To All Objects
// ----------------------------------------------------------------------------------
@Override
public boolean equals(final Object o) {
if (o == this) return true;
@ -95,12 +109,21 @@ public class ChecklistAnswer extends DomainObject {
&& Objects.equals(this.getId(), other.getId());
}
protected boolean canEqual(final Object other) {
return other instanceof ChecklistAnswer;
}
@Override
public int hashCode() {
return Objects.hashCode(this.getId());
}
@Override
public String toString() {
return "ChecklistAnswer(id=" + this.getId() + ", answer=" + this.getAnswer() + ", user=" + this.getUser() +
", comment=" + this.getComment() + ")";
}
// ----------------------------------------------------------------------------------
// Other Methods
// ----------------------------------------------------------------------------------
protected boolean canEqual(final Object other) {
return other instanceof ChecklistAnswer;
}
}

View File

@ -1363,6 +1363,9 @@ alter table `checklist_answer`
foreign key (user_id) references user (id)
on delete cascade on update cascade;
-- update to NOT_APPLICABLE because of typo in code
update `checklist_answer` set answer = 'NOT_APPLICABLE' where answer = 'NOT_APLICABLE';
-- table: checklist_question
alter table `checklist_question` rename column `questionNumber` to `question_number`;