list script and testplan by time desc

This commit is contained in:
hmm 2014-09-03 14:30:05 +08:00
parent 82f2fe2546
commit 230a2e23ca
2 changed files with 3 additions and 2 deletions

View File

@ -11,6 +11,7 @@ import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Component;
@ -116,7 +117,7 @@ public class ScriptRepositoty extends AbstractRepositoty {
Session session = this.getSessionHelper().openSession();
@SuppressWarnings("unchecked")
List<Script> scripts = session.createCriteria(Script.class)
.add(Restrictions.eq("user", user))
.add(Restrictions.eq("user", user)).addOrder(Order.desc("createDateTime"))
.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).list();
releaseSession(session);
return scripts;

View File

@ -121,7 +121,7 @@ public class TestPlanRepository extends AbstractRepositoty {
try {
@SuppressWarnings("unchecked")
List<TestPlan> ret = session.createCriteria(TestPlan.class)
.add(Restrictions.eq("user", user))
.add(Restrictions.eq("user", user)).addOrder(Order.desc("lastRunningTime"))
.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).list();
return ret;
} catch (Exception e) {