Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
2.1, Oracle 9
I essentially have the Item and Bid relationship described in Hibernate in Action. I'm trying to return a [b]paged[b] set of Items ordered by the highest bid.
Because I'm paging, using a HashSet to remove non-distinct items after the query isn't an option. I need the HQL to make them distinct and then return the correct page of distinct objects.
Here's a working query that works, but doesn't return distinct Items.
select i from Item i
left join fetch s.bids bid
order by bid.amount
To make it distinct, I tried in the distinct keyword.
select distinct i from Item i
left join fetch s.bids bid
order by bid.amount
This however fails with the error (one of my "Bid" columns is a CLOB):
18:00:24,403 WARN JDBCExceptionReporter:38 - SQL Error: 932, SQLState: 42000
18:00:24,403 ERROR JDBCExceptionReporter:46 - ORA-00932: inconsistent datatypes: expected - got CLOB
I can't do the paging unless I can make distinct work (no point in paging non-distinct values). I'm assuming it's an issue with trying this against Orcale (saw a similar thread on DB2 issues). I really don't want to do the distinct and paging in Java though as that'd be woefully ineffecient compared to the database, not to mention retrieving way more data than I need.
Any ideas? A possible thought is only joining with the set of Bids that contain the highest bid for each Item, which would effectively make it distinct, but as of yet I can't figure out how to create that query.