last day (15 days later) » 

11:30 AM
0
A: Hibernate 2 with MSSQL for ORDER BY

Subodh JoshiLook Like you mix aggregate and non-aggregate expressions .If you are using any aggregate function like AVG() in Select query with some other non-aggregate then you must use Group By .. Try something like this createQuery("SELECT SUM(tcs.dueAmount) As DueAmount ... If you are using Criteria...

 
I have edited the question please take a look at the last lines
 
Where is your query? Please share it also
 
Edited again. please check
 
In your Criteria query give some name to SUM(tcs.dueAmount) dont directly use it also you told you are using criteria but here you used createQuery ?
 
like, "SUM(tcs.dueAmount) as sum" ?
 
11:30 AM
Check edited answer
Yes right try with that
 
Yeah not here, there are other places I Have used criteria
List cancelList = cancelStatusCriteria.list(); criteria.add(Restrictions.eq("companyId", userConfig.getCompanyId())); if ((cancelList!=null)&&(cancelList.size()>0)) criteria.add(Restrictions.not(Restrictions.in("applicationStatusId", cancelStatusCriteria.list()))); //criteria.addOrder(Order.asc("applicationId")); criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); if (to != -1) { criteria.setFirstResult(from); criteria.setMaxResults(to); } Collection<Application> collection=criteria.list();
Didn't work like that :(
 
@Sachi Pj you share query and now you made changes in Criteria ? Are you Using SQL or Criteria?
 
these are two different programs. One in query and one in criteria. Both give errors and both work if I remove the order by.
 
Ok i bit confuse somewhere you have added SQL code and not the criteria
 
Yes I badly need solutions for both these matters. Query or criteria both gives me errors
 
11:30 AM
See i have already edited answer.
Both giving exception is mean you are doing something wrong
Is your issue resolved or not?
 
No where's order by?
 
I mentioned how it would work
r u there?
Sorry to say it will hard to help if u will reply too late
 

  last day (15 days later) »