trying to refactor
This commit is contained in:
parent
f17dd98137
commit
916ed6eb1a
resources/db_update_scripts
src/main/java/se/su/dsv/scipro/match/dataobject
@ -1 +1,4 @@
|
||||
DROP TABLE role_Language;
|
||||
DROP TABLE role_Language;
|
||||
|
||||
ALTER TABLE newidea_student DROP PRIMARY KEY;
|
||||
ALTER TABLE newidea_student ADD `id` bigint(20) NOT NULL AUTO_INCREMENT;
|
@ -37,8 +37,10 @@ public class NewIdea extends DomainObject implements Membership {
|
||||
@Column(nullable = true, length = 4000)
|
||||
private String prerequisites;
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY, mappedBy = "key.idea", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
@QueryInit("newIdeaParticipations.key.student")
|
||||
// @OneToMany(fetch = FetchType.LAZY, mappedBy = "key.idea", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
@OneToMany(fetch = FetchType.LAZY, mappedBy = "idea", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
// @QueryInit("newIdeaParticipations.key.student")
|
||||
@QueryInit("student")
|
||||
private Set<NewIdeaParticipation> newIdeaParticipations = new HashSet<NewIdeaParticipation>();
|
||||
|
||||
@ManyToOne(optional = true)
|
||||
|
@ -12,9 +12,9 @@ import java.util.Date;
|
||||
@Entity
|
||||
@Table(name = "newidea_student")
|
||||
@AssociationOverrides({
|
||||
@AssociationOverride(name = "key.student",
|
||||
@AssociationOverride(name = "student",
|
||||
joinColumns = @JoinColumn(name = "role_id")),
|
||||
@AssociationOverride(name = "key.idea",
|
||||
@AssociationOverride(name = "idea",
|
||||
joinColumns = @JoinColumn(name = "idea_id")) })
|
||||
public class NewIdeaParticipation implements Serializable {
|
||||
private static final long serialVersionUID = 7226582762480962022L;
|
||||
@ -29,10 +29,20 @@ public class NewIdeaParticipation implements Serializable {
|
||||
this.dateCreated = dateCreated;
|
||||
this.confirmed = confirmed;
|
||||
}
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
@EmbeddedId
|
||||
@QueryInit("student")
|
||||
private NewIdeaParticipationId key = new NewIdeaParticipationId();
|
||||
// @EmbeddedId
|
||||
// @QueryInit("student")
|
||||
// private NewIdeaParticipationId key = new NewIdeaParticipationId();
|
||||
|
||||
@ManyToOne
|
||||
private Student student;
|
||||
|
||||
@ManyToOne
|
||||
private NewIdea idea;
|
||||
|
||||
@Column(name = "confirmed")
|
||||
private boolean confirmed;
|
||||
@ -40,59 +50,35 @@ public class NewIdeaParticipation implements Serializable {
|
||||
@NotNull
|
||||
private Date dateCreated;
|
||||
|
||||
public void setConfirmed(boolean confirmed) {
|
||||
this.confirmed = confirmed;
|
||||
}
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public boolean isConfirmed() {
|
||||
return confirmed;
|
||||
}
|
||||
public Student getStudent() {
|
||||
return student;
|
||||
}
|
||||
|
||||
public void setKey(NewIdeaParticipationId key) {
|
||||
this.key = key;
|
||||
}
|
||||
public void setStudent(Student student) {
|
||||
this.student = student;
|
||||
}
|
||||
|
||||
public NewIdeaParticipationId getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
@Transient
|
||||
public Student getStudent() {
|
||||
return getKey().getStudent();
|
||||
}
|
||||
|
||||
public void setStudent(Student student) {
|
||||
getKey().setStudent(student);
|
||||
}
|
||||
|
||||
@Transient
|
||||
public NewIdea getIdea() {
|
||||
return getKey().getIdea();
|
||||
}
|
||||
|
||||
public void setIdea(NewIdea idea) {
|
||||
getKey().setIdea(idea);
|
||||
}
|
||||
public NewIdea getIdea() {
|
||||
return idea;
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if(o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
NewIdeaParticipation idea = (NewIdeaParticipation) o;
|
||||
|
||||
if(getKey() != null ? !getKey().equals(idea.getKey()):idea.getKey()!=null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return (getKey()!=null?getKey().hashCode() : 0);
|
||||
}
|
||||
public void setIdea(NewIdea idea) {
|
||||
this.idea = idea;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConfirmed() {
|
||||
return confirmed;
|
||||
}
|
||||
|
||||
public void setConfirmed(boolean confirmed) {
|
||||
this.confirmed = confirmed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getStudent().getNameAsString();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user