-->
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.  [ 2 posts ] 
Author Message
 Post subject: Getting error: Need to modify a query from the auction ex.
PostPosted: Mon Jun 07, 2004 1:48 pm 
Newbie

Joined: Tue Apr 13, 2004 9:47 am
Posts: 4
Location: Atlanta, Ga
Version: 2.1
Database: MySQL V4

Using the auction example as a basis and have the follwing query from the example:

Code:

List auctions = s.createQuery(
            "select new AuctionInfo( item.id, item.description, item.ends,
            item.seller, max (bid.amount) ) "
+ "from AuctionItem item "
+ "left join item.bids bid "
+ "group by item.id, item.description, item.ends "
+ "order by item.ends desc")
.list();



I want to use the query above to get back the items and bids by a particular user id and added to the query as follows:

Code:

List auctions = session.createQuery(
              "select new AuctionInfo( item.id, item.description, item.ends, item.seller, max(bid.amount) ) "
              + "from AuctionItem item "
              + "where item.seller = " + user.getId().toString() + " "
              + "left join item.bids bid "
              + "group by item.id, item.description, item.ends, item.seller "
              + "order by item.ends desc"
              )
              .list();



I get the following error:

net.sf.hibernate.QueryException: unindexed collection before []: auctionite0_.bids [select new AuctionInfo( item.id, item.description, item.ends, item.seller, max(bid.amount) ) from com.cin
gular.auction.value.AuctionItem item where item.seller = 1 left join item.bids bid group by item.id, item.description, item.ends, item.seller order by item.ends desc]

I am new to doing queries and did ok up to this point but I could use a little help figuring this one out to get back this list by user id. I have it working in plain old SQL.

Thanks for any help.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 07, 2004 1:54 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
you have a "left join" in the where clause - it goes in the from clause


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.