task/3382: Harmonisera tabellnamn #6
@ -1,11 +1,22 @@
|
|||||||
package se.su.dsv.scipro.checklist;
|
package se.su.dsv.scipro.checklist;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.EnumType;
|
||||||
|
import jakarta.persistence.Enumerated;
|
||||||
|
import jakarta.persistence.GeneratedValue;
|
||||||
|
import jakarta.persistence.GenerationType;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.JoinColumn;
|
||||||
|
import jakarta.persistence.Lob;
|
||||||
|
import jakarta.persistence.ManyToOne;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
import se.su.dsv.scipro.system.DomainObject;
|
import se.su.dsv.scipro.system.DomainObject;
|
||||||
import se.su.dsv.scipro.system.User;
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "checklist_answer")
|
@Table(name = "checklist_answer")
|
||||||
public class ChecklistAnswer extends DomainObject {
|
public class ChecklistAnswer extends DomainObject {
|
||||||
@ -14,10 +25,11 @@ public class ChecklistAnswer extends DomainObject {
|
|||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Enumerated(EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
@Column(nullable = false)
|
@Column(name = "answer", nullable = false)
|
||||||
private ChecklistAnswerEnum answer;
|
private ChecklistAnswerEnum answer;
|
||||||
|
|
||||||
@ManyToOne(optional = false)
|
@ManyToOne(optional = false)
|
||||||
|
@JoinColumn(name = "user_id")
|
||||||
private User user;
|
private User user;
|
||||||
|
|
||||||
@Lob
|
@Lob
|
||||||
|
@ -1,13 +1,26 @@
|
|||||||
package se.su.dsv.scipro.checklist;
|
package se.su.dsv.scipro.checklist;
|
||||||
|
|
||||||
import se.su.dsv.scipro.system.DomainObject;
|
|
||||||
import se.su.dsv.scipro.system.User;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import jakarta.persistence.Basic;
|
||||||
|
import jakarta.persistence.Cacheable;
|
||||||
|
import jakarta.persistence.CascadeType;
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.GeneratedValue;
|
||||||
|
import jakarta.persistence.GenerationType;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.JoinColumn;
|
||||||
|
import jakarta.persistence.JoinTable;
|
||||||
|
import jakarta.persistence.Lob;
|
||||||
|
import jakarta.persistence.OneToMany;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
|
import se.su.dsv.scipro.system.DomainObject;
|
||||||
|
import se.su.dsv.scipro.system.User;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "checklist_question")
|
@Table(name = "checklist_question")
|
||||||
@Cacheable(true)
|
@Cacheable(true)
|
||||||
@ -20,13 +33,15 @@ public class ChecklistQuestion extends DomainObject {
|
|||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
private String question;
|
private String question;
|
||||||
|
|
||||||
@Column(nullable = false)
|
@Basic
|
||||||
|
@Column(name = "question_number", nullable = false)
|
||||||
private int questionNumber;
|
private int questionNumber;
|
||||||
|
|
||||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
|
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
|
||||||
@JoinTable(
|
@JoinTable(
|
||||||
joinColumns = @JoinColumn(name = "checklist_question_id")
|
name = "checklist_question_checklist_answer",
|
||||||
)
|
joinColumns = @JoinColumn(name = "checklist_question_id", referencedColumnName = "id"),
|
||||||
|
inverseJoinColumns = @JoinColumn(name = "checklist_answer_id", referencedColumnName = "id"))
|
||||||
private List<ChecklistAnswer> answers = new ArrayList<>();
|
private List<ChecklistAnswer> answers = new ArrayList<>();
|
||||||
|
|
||||||
protected ChecklistQuestion() {
|
protected ChecklistQuestion() {
|
||||||
|
@ -1312,9 +1312,41 @@ alter table `checklist`
|
|||||||
foreign key (project_id) references project (id)
|
foreign key (project_id) references project (id)
|
||||||
on delete cascade on update cascade;
|
on delete cascade on update cascade;
|
||||||
|
|
||||||
|
-- table : checklist_question_checklist_answer
|
||||||
|
|
||||||
|
alter table `checklist_question_checklist_answer` drop foreign key `FK86395A5787D18D44`;
|
||||||
|
alter table `checklist_question_checklist_answer` drop foreign key `FK86395A574BFBD702`;
|
||||||
|
alter table `checklist_question_checklist_answer` drop key `FK86395A574BFBD702`;
|
||||||
|
alter table `checklist_question_checklist_answer` drop key `UK_47is0po5b69467hxbgr4a2gph`;
|
||||||
|
alter table `checklist_question_checklist_answer` drop key `answers_id`;
|
||||||
|
|
||||||
|
alter table `checklist_question_checklist_answer` rename column `answers_id` to `checklist_answer_id`;
|
||||||
|
|
||||||
|
alter table `checklist_question_checklist_answer` add constraint uk_cq_ca_checklist_answer_id unique(checklist_answer_id);
|
||||||
|
|
||||||
|
alter table `checklist_question_checklist_answer`
|
||||||
|
add constraint fk_cq_ca_checklist_answer_id
|
||||||
|
foreign key (checklist_answer_id) references checklist_answer (id)
|
||||||
|
on delete cascade on update cascade;
|
||||||
|
|
||||||
|
alter table `checklist_question_checklist_answer`
|
||||||
|
add constraint fk_cq_ca_checklist_question_id
|
||||||
|
foreign key (checklist_question_id) references checklist_question (id)
|
||||||
|
on delete cascade on update cascade;
|
||||||
|
|
||||||
|
-- table: checklist_answer
|
||||||
|
|
||||||
|
alter table `checklist_answer` drop foreign key `FK49936477895349BF`;
|
||||||
|
alter table `checklist_answer` drop key `FK49936477895349BF`;
|
||||||
|
|
||||||
|
alter table `checklist_answer`
|
||||||
|
add constraint fk_checklist_answer_user_id
|
||||||
|
foreign key (user_id) references user (id)
|
||||||
|
on delete cascade on update cascade;
|
||||||
|
|
||||||
|
-- table: checklist_question
|
||||||
|
|
||||||
|
alter table `checklist_question` rename column `questionNumber` to `question_number`;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user