Hibernate version: 3.1.3
Hi all,
I'm trying to optimise a query for mysql 5.x which was written like this:
Code:
SELECT phraseSearchSummary.phrase
FROM PhraseSearchSummary AS phraseSearchSummary
WHERE phraseSearchSummary.phrase IN
(SELECT innerPhraseSearchWord.phrase
FROM PhraseSearchInventoryWord AS innerPhraseSearchWord
WHERE innerPhraseSearchWord.word.word IN (:words)
GROUP BY innerPhraseSearchWord.phrase
HAVING COUNT(*) = :numberOfWords)
Into something like this, which tries to join onto a select view:
Code:
SELECT phraseSearchSummary.phrase
FROM PhraseSearchSummary AS phraseSearchSummary,
(SELECT innerPhraseSearchWord.phrase AS phrase
FROM PhraseSearchInventoryWord AS innerPhraseSearchWord
WHERE innerPhraseSearchWord.word.word IN (:words)
GROUP BY innerPhraseSearchWord.phrase
HAVING COUNT(*) = :numberOfWords) AS wordSummary
WHERE phraseSearchSummary.phrase.id = wordSummary.phrase.id
The new query when run in SQL runs over 40x faster however the HQL version above fails to load when hibernate starts up with the standard error message saying "Errors in named queries". Is this kind of query possible?