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.