Hi,
i need help in using native sql query. i have a query like this :
Code:
public class ArrivalReportBean {
private SessionFactory sf;
private final String query = "SELECT h.dateTr,111, h.noTr, dt.pKey, SUM(dt.quantity) * -1, dt.unitPrice, " +
"SUM(dt.quantity) * -1 * dt.unitPrice FROM detailTransaction dt, header h " +
"WHERE h.noTr = dt.noTr AND h.dateTr >= '2009-1-10' AND h.dateTr <= '2009-7-15' " +
"AND dt.NDC = 'J' GROUP BY h.dateTr,h.noTr, dt.pKey, dt.quantity, dt.unitPrice " +
"ORDER BY h.noTr COMPUTE SUM((SUM(dt.quantity) * -1 * dt.unitPrice)) BY h.noTr " +
"COMPUTE SUM((SUM(dt.quantity) * -1 * dt.unitPrice))";
public ArrivalReportBean(SessionFactory sf){
this.sf = sf;
}
public void test(){
Session session = sf.openSession();
Query q = session.createSQLQuery(query);
q.list();
}
}
once i want to generate list from query, it always throw exception. is there any mistake in my query statement? or there's something i missed from the statement? really need help...
the query is SQL Server 2005 based query and it works fine once i execute it via SQL Server management studio..