-->
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: Error while using Iterator in Hibernate SQL Query
PostPosted: Thu May 14, 2009 12:38 am 
Newbie

Joined: Thu May 14, 2009 12:30 am
Posts: 1
Hi ALL,

I used this code...

Code:
q=ses.createSQLQuery("SELECT master_shelfitems.shelf_itemid,master_shelfitems.shelf_id,master_shelf.shelf_name,master_shelfitems.product_id,SUM(daily_productstock.productstock) FROM master_shelfitems INNER JOIN master_shelf ON (master_shelfitems.shelf_id=master_shelf.shelf_id) INNER JOIN master_product ON (master_shelfitems.product_id=master_product.product_id) INNER JOIN master_productbatch ON (master_product.product_id=master_productbatch.product_id)INNER JOIN daily_productstock ON (master_productbatch.productbatch_code=daily_productstock.productbatch_code) where productstock_date between '"+start+"' and '"+end+"' and master_shelfitems.is_deleted=0 GROUP BY master_shelfitems.shelf_id,master_shelf.shelf_name,master_shelfitems.product_id");
for(Iterator it=q.iterate();it.hasNext();)
{
ShelfItems shelfItems=new ShelfItems();
                    Shelf shelf1=new Shelf();
                    Product product1=new Product();
                    Object o[]=(Object[])it.next();
                    shelfItems.setShelf_itemid(Integer.parseInt(o[0].toString()));
                    String shelfid=o[1].toString();
                    shelf1=(Shelf)getHibernateTemplate().load(Shelf.class,Integer.parseInt(shelfid));
                    shelfItems.setShelf_id(shelf1);
                    shelfItems.setShelf_name1(o[2].toString());
                    String pid=o[3].toString();
                    logger.info("Hibernate...Product id is"+pid+"and shelf id is"+shelfid);
                    product1=(Product)getHibernateTemplate().load(Product.class,Integer.parseInt(pid));
                    shelfItems.setProduct_id(product1);                   
                    shelfItems.setStock(Double.parseDouble(o[4].toString()));
                    shelfItems.setRemarks(o[3].toString());
                    arr.add(shelfItems);
}


I got an error like SQL does not currently support Iterator...
I tried changing createSQLQuery to createQuery...
But then I got an error for 'ON' keyword in my join query....
Please help me...


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.