-->
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: problem with native sql query
PostPosted: Sat May 10, 2008 7:30 am 
Newbie

Joined: Sat May 10, 2008 7:04 am
Posts: 2
Hi, I have the following query

SELECT 0 ORD_PID_ORDER_DETAIL,
ORD_PID_STOCK,
ORD_DTE_ORDER,
ORD_PID_CUSTOMER ,
SUM(INP_NBR_QTY) ORD_NBR_ORDER_QTY,
sum(INP_AMT_AMOUNT) ORD_AMT_AMOUNT
from(
select
INP_PID_STOCK ORD_PID_STOCK,
INP_DTE_ORDER ORD_DTE_ORDER,
INP_NBR_QTY,
INP_AMT_AMOUNT,
(select name from name_table where code=INP_CDE_NAME) NAME
FROM
TLD_INP_INPUT_PRDER
WHERE
INP_PID_PRODUCT=3
)
GROUP BY
ORD_PID_STOCK,
ORD_DTE_ORDER,
ORD_PID_CUSTOMER

I want to store this data into TLD_ORD_ORDER_DETAIL table.

The following code is used




SQLQuery q = getSession().createSQLQuery("SELECT 0 ORD_PID_ORDER_DETAIL,ORD_PID_STOCK,ORD_DTE_ORDER, ORD_PID_CUSTOMER ,SUM(INP_NBR_QTY) ORD_NBR_ORDER_QTY,sum(INP_AMT_AMOUNT) ORD_AMT_AMOUNT from( select INP_PID_STOCK ORD_PID_STOCK, INP_DTE_ORDER ORD_DTE_ORDER,INP_NBR_QTY, INP_AMT_AMOUNT,(select name from name_table where code=INP_CDE_NAME) NAME
FROM TLD_INP_INPUT_PRDER WHERE INP_PID_PRODUCT=3 ) GROUP BY ORD_PID_STOCK, ORD_DTE_ORDER, ORD_PID_CUSTOMER");


q.addEntity(Order.class);

List<Order> orders= q.list();

for(Order newOrder :orders)
{
System.out.println("newOrderid----->"+newOrder.getOrdPidOrderDetail());
System.out.println("newOrderscustomer----->"+newOrder.getTldCustomer().getCusPidCustomer());
System.out.println("newOrdersquantity----->"+newOrder.getOrdNbrOrderQty());

}

ORD_PID_ORDER_DETAIL is the primary key column in Order detail table the curresponding entity is Order. The query while executing thru TOAD gives 3 distinct results. but after executing this query thru hibernate 3 objects are obtained but with exact same data.

Pls help me in resolving this problem.

Thanks
Augba

[/quote]


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.