-->
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.  [ 3 posts ] 
Author Message
 Post subject: Query won't work
PostPosted: Wed Aug 18, 2010 7:17 am 
Newbie

Joined: Wed Aug 18, 2010 6:43 am
Posts: 10
Hi all

I'm very new to Hibernate can someone please tell me what am I doing wrong with this query;

Code:
@NamedQuery(name = "PurchaseOrder.findAll", query = "SELECT p FROM PurchaseOrder p ORDER BY p.purchaseOrderDate DESC")
@Formula(value = "(select sum(pot.TRAN_QUANTITY) FROM PURCHASE_ORDER_PROD_TRAN pot, PURCHASE_ORDER p where p.PURCHASE_ORDER_ID = pot.PURCHASE_ORDER_ID group by p.PURCHASE_ORDER_ID)")
private int purchaseOrderQuantity;


I'm using the same query in SQL developer (using SQL syntax) it works fine, but here I'm getting this error;
Quote:
java.sql.SQLException: ORA-01427: single-row subquery returns more than one row

Any thoughts anyone????


Top
 Profile  
 
 Post subject: Re: Query won't work
PostPosted: Wed Aug 18, 2010 4:06 pm 
Newbie

Joined: Tue Aug 17, 2010 3:29 pm
Posts: 12
Quote:
@Formula(value = "(select sum(pot.TRAN_QUANTITY) FROM PURCHASE_ORDER_PROD_TRAN pot, PURCHASE_ORDER p where p.PURCHASE_ORDER_ID = pot.PURCHASE_ORDER_ID group by p.PURCHASE_ORDER_ID)")


I think the above highlighted with bold letters is causing the problem. group by will return multiple rows which is not acceptable in this case.


Top
 Profile  
 
 Post subject: Re: Query won't work
PostPosted: Wed Aug 18, 2010 5:30 pm 
Newbie

Joined: Wed Aug 18, 2010 6:43 am
Posts: 10
Thanks for your reply, I have tried it the way you described, it just gives me a different error. I've taken a different approach now.

Zed


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

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.