|
48 | 48 | //TODO: test all three UniqueConstraints |
49 | 49 | @Index(name = "ix_task_uuid", columnList = "uuid"), |
50 | 50 | @Index(name = "ix_task_row_created_at", columnList = "row_created_at"), |
51 | | - @Index(name = "ix_task_title", columnList = "title") |
| 51 | + @Index(name = "ix_task_title", columnList = "title"), |
| 52 | + @Index(name = "ix_task_order_id_task_state", columnList = "order_id_task_state"), |
| 53 | + @Index(name = "ix_task_order_id_project", columnList = "order_id_project,data_project_id") |
52 | 54 | } |
53 | 55 | ) |
54 | 56 | @NamedQueries({ |
55 | 57 | @NamedQuery( |
56 | 58 | name = "queryGetTasksByOrderIdTaskStateBetweenLowerTaskAndHigherTask", |
57 | 59 | query = "select t from Task t" |
58 | 60 | + " where t.orderIdTaskState > :lowerOrderIdTaskState and t.orderIdTaskState < :higherOrderIdTaskState" |
59 | | - + " and t.taskState = :taskState and t.context = :context", |
| 61 | + + " and t.taskState = :taskState and t.context = :context order by t.orderIdTaskState ", |
60 | 62 | lockMode = LockModeType.READ |
61 | 63 | ), |
62 | 64 | @NamedQuery( |
63 | 65 | name = "queryGetTasksByOrderIdProjectBetweenLowerTaskAndHigherTask", |
64 | 66 | query = "select t from Task t" |
65 | 67 | + " where t.orderIdProject > :lowerOrderIdProject and t.orderIdProject < :higherOrderIdProject" |
66 | | - + " and t.project = :project", |
| 68 | + + " and t.project = :project order by t.orderIdProject DESC ", |
67 | 69 | lockMode = LockModeType.READ |
68 | 70 | ), |
69 | 71 | @NamedQuery( |
70 | 72 | name = "queryGetTasksByOrderIdProjectRootBetweenLowerTaskAndHigherTask", |
71 | 73 | query = "select t from Task t" |
72 | 74 | + " where t.orderIdProject > :lowerOrderIdProject and t.orderIdProject < :higherOrderIdProject" |
73 | | - + " and t.project is null and t.context = :context ", |
| 75 | + + " and t.project is null and t.context = :context order by t.orderIdProject DESC ", |
74 | 76 | lockMode = LockModeType.READ |
75 | 77 | ), |
76 | 78 | @NamedQuery( |
77 | 79 | name = "findByTaskStateInbox", |
78 | 80 | query = "select t from Task t " + |
79 | 81 | "where t.taskState = org.woehlke.java.simpleworklist.domain.db.data.task.TaskState.INBOX " + |
80 | | - "and t.context = :context", |
| 82 | + "and t.context = :context order by t.orderIdTaskState DESC ", |
81 | 83 | lockMode = LockModeType.READ |
82 | 84 | ), |
83 | 85 | @NamedQuery( |
84 | 86 | name = "findByTaskStateToday", |
85 | 87 | query = "select t from Task t " + |
86 | 88 | "where t.taskState = org.woehlke.java.simpleworklist.domain.db.data.task.TaskState.TODAY " + |
87 | | - "and t.context = :context", |
| 89 | + "and t.context = :context order by t.orderIdTaskState DESC ", |
88 | 90 | lockMode = LockModeType.READ |
89 | 91 | ), |
90 | 92 | @NamedQuery( |
91 | 93 | name = "findByTaskStateNext", |
92 | 94 | query = "select t from Task t " + |
93 | 95 | "where t.taskState = org.woehlke.java.simpleworklist.domain.db.data.task.TaskState.NEXT " + |
94 | | - "and t.context = :context", |
| 96 | + "and t.context = :context order by t.orderIdTaskState DESC ", |
95 | 97 | lockMode = LockModeType.READ |
96 | 98 | ), |
97 | 99 | @NamedQuery( |
98 | 100 | name = "findByTaskStateWaiting", |
99 | 101 | query = "select t from Task t " + |
100 | 102 | "where t.taskState = org.woehlke.java.simpleworklist.domain.db.data.task.TaskState.WAITING " + |
101 | | - "and t.context = :context", |
| 103 | + "and t.context = :context order by t.orderIdTaskState DESC ", |
102 | 104 | lockMode = LockModeType.READ |
103 | 105 | ), |
104 | 106 | @NamedQuery( |
105 | 107 | name = "findByTaskStateScheduled", |
106 | 108 | query = "select t from Task t " + |
107 | 109 | "where t.taskState = org.woehlke.java.simpleworklist.domain.db.data.task.TaskState.SCHEDULED " + |
108 | | - "and t.context = :context", |
| 110 | + "and t.context = :context order by t.orderIdTaskState DESC ", |
109 | 111 | lockMode = LockModeType.READ |
110 | 112 | ), |
111 | 113 | @NamedQuery( |
112 | 114 | name = "findByTaskStateSomeday", |
113 | 115 | query = "select t from Task t " + |
114 | 116 | "where t.taskState = org.woehlke.java.simpleworklist.domain.db.data.task.TaskState.SOMEDAY " + |
115 | | - "and t.context = :context", |
| 117 | + "and t.context = :context order by t.orderIdTaskState DESC ", |
116 | 118 | lockMode = LockModeType.READ |
117 | 119 | ), |
118 | 120 | @NamedQuery( |
119 | 121 | name = "findByTaskStateCompleted", |
120 | 122 | query = "select t from Task t " + |
121 | 123 | "where t.taskState = org.woehlke.java.simpleworklist.domain.db.data.task.TaskState.COMPLETED " + |
122 | | - "and t.context = :context", |
| 124 | + "and t.context = :context order by t.orderIdTaskState DESC ", |
123 | 125 | lockMode = LockModeType.READ |
124 | 126 | ), |
125 | 127 | @NamedQuery( |
126 | 128 | name = "findByTaskStateDeleted", |
127 | 129 | query = "select t from Task t " + |
128 | 130 | "where t.taskState = org.woehlke.java.simpleworklist.domain.db.data.task.TaskState.DELETED " + |
129 | | - "and t.context = :context", |
| 131 | + "and t.context = :context order by t.orderIdTaskState DESC ", |
130 | 132 | lockMode = LockModeType.READ |
131 | 133 | ), |
132 | 134 | @NamedQuery( |
133 | 135 | name = "findByTaskStateTrash", |
134 | 136 | query = "select t from Task t " + |
135 | 137 | "where t.taskState = org.woehlke.java.simpleworklist.domain.db.data.task.TaskState.TRASH " + |
136 | 138 | "or t.taskState = org.woehlke.java.simpleworklist.domain.db.data.task.TaskState.DELETED " + |
137 | | - "and t.context = :context", |
| 139 | + "and t.context = :context order by t.orderIdTaskState DESC ", |
138 | 140 | lockMode = LockModeType.READ |
139 | 141 | ), |
140 | 142 | @NamedQuery( |
141 | 143 | name = "findByTaskStateProjects", |
142 | 144 | query = "select t from Task t " + |
143 | 145 | "where t.taskState = org.woehlke.java.simpleworklist.domain.db.data.task.TaskState.PROJECTS " + |
144 | | - "and t.context = :context", |
| 146 | + "and t.context = :context order by t.orderIdTaskState DESC ", |
145 | 147 | lockMode = LockModeType.READ |
146 | 148 | ) |
147 | 149 | }) |
|
0 commit comments