Fix intermittent sorting of criterion to actual order (#18)
When you tried to edit a grading template in "Project management" -> "Grading Templates" the criterion could be shown in an order not reflecting the sortOrder of the criterion. The reason was that we only got the arbitrary order depending on the insertion order in the database. Changed the Collection to a List, it is now an ArrayList. Also added @OrderBy("sortOrder ASC") to actually sort by the order of the criterion thus ensuring visual order is intact. Co-authored-by: Tom Zhao <tom.zhao@dsv.su.se> Reviewed-on: #18 Reviewed-by: Tom Zhao <tom.zhao@dsv.su.se> Co-authored-by: Nico Athanassiadis <nico@dsv.su.se> Co-committed-by: Nico Athanassiadis <nico@dsv.su.se>
This commit is contained in:
parent
a9b8542576
commit
d89417ceea
@ -10,6 +10,7 @@ import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.OneToOne;
|
||||
import jakarta.persistence.OrderBy;
|
||||
import jakarta.persistence.Table;
|
||||
import jakarta.persistence.Temporal;
|
||||
import jakarta.persistence.TemporalType;
|
||||
@ -22,7 +23,6 @@ import se.su.dsv.scipro.system.User;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@ -62,7 +62,8 @@ public class GradingReportTemplate extends DomainObject {
|
||||
// JPA-mappings of other tables referencing to this table "grading_report_template"
|
||||
// ----------------------------------------------------------------------------------
|
||||
@OneToMany(mappedBy = "gradingReportTemplate", cascade = {CascadeType.ALL}, orphanRemoval = true)
|
||||
private Collection<GradingCriterionTemplate> criteria = new HashSet<>();
|
||||
@OrderBy("sortOrder ASC")
|
||||
private List<GradingCriterionTemplate> criteria = new ArrayList<>();
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
@JoinColumn(name = "grading_report_template_id", referencedColumnName = "id")
|
||||
|
Loading…
x
Reference in New Issue
Block a user