-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Need help on using Native SQL Query
PostPosted: Mon Jun 22, 2009 11:36 am 
Newbie

Joined: Fri Jun 19, 2009 1:20 pm
Posts: 4
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..


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.