migue/liferay-portal — pull request #53 by giros (2012-07-17 11:04:55+00:00)
Title: LPS-27737 Fixing sub-query to resolve Hibernate error

Hi Miguel, this is the pull request you asked for in LPS-28613.

The logic of the fix has already been committed by commits:
b303ae371c24594b4362a34a8174b3bae61c2c7c
805ec84379dfe5f235978951e45d45b90a2fbad7
e110f97feb82aec95f87442b07b9138a1587e7d5

But the new query added to portal.xml that is used as a sub-query (if needed) was unparse-able by Hibernate, as we described earlier. The form of the query included in this pull request is the only with which I could make it work, but it uses table aliases. Hopefully it's still acceptable.

Please note that it's hard to test this, as the sub-query is used only if there is a high amount of resource blocks. I was using a sample DB that the customer sent.