Order tags by name in all requests

This commit is contained in:
jendib 2013-08-04 16:45:37 +02:00
parent 0ab480165c
commit 363d6eef23
2 changed files with 3 additions and 2 deletions

View File

@ -45,7 +45,7 @@ public class TagDao {
@SuppressWarnings("unchecked")
public List<Tag> getByUserId(String userId) {
EntityManager em = ThreadLocalContext.get().getEntityManager();
Query q = em.createQuery("select t from Tag t where t.userId = :userId and t.deleteDate is null order by t.id");
Query q = em.createQuery("select t from Tag t where t.userId = :userId and t.deleteDate is null order by t.name");
q.setParameter("userId", userId);
return q.getResultList();
}
@ -118,6 +118,7 @@ public class TagDao {
sb.append(" left join T_DOCUMENT d on d.DOC_ID_C = dt.DOT_IDDOCUMENT_C and d.DOC_DELETEDATE_D is null and d.DOC_IDUSER_C = :userId ");
sb.append(" where t.TAG_DELETEDATE_D is null ");
sb.append(" group by t.TAG_ID_C ");
sb.append(" order by t.TAG_NAME_C ");
// Perform the query
Query q = em.createNativeQuery(sb.toString());

View File

@ -110,7 +110,7 @@ public class TestTagResource extends BaseJerseyTest {
json = response.getEntity(JSONObject.class);
tags = json.getJSONArray("tags");
Assert.assertTrue(tags.length() > 0);
Assert.assertEquals("Updated name", tags.getJSONObject(0).getString("name"));
Assert.assertEquals("Updated name", tags.getJSONObject(1).getString("name"));
// Deletes a tag
tagResource = resource().path("/tag/" + tag4Id);